rellic icon indicating copy to clipboard operation
rellic copied to clipboard

Lifting this bitcode results in a return 1u

Open pgoodman opened this issue 4 years ago • 1 comments

; ModuleID = '/tmp/challenge-3/program_c/src/main.ll'
source_filename = "main.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu-elf"

%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, %struct._IO_codecvt*, %struct._IO_wide_data*, %struct._IO_FILE*, i8*, i64, i32, [20 x i8] }
%struct._IO_marker = type opaque
%struct._IO_codecvt = type opaque
%struct._IO_wide_data = type opaque
%struct.Bumper = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i64, i64 }
%struct.fd_set = type { [16 x i64] }
%struct.timeval = type { i64, i64 }
%struct.sockaddr = type { i16, [14 x i8] }

@__anvill_sp = external global i8
@__anvill_ra = external global i8
@llvm.compiler.used = appending global [27 x i8*] [i8* bitcast (i8* (i8*, i8*)* @strcpy to i8*), i8* bitcast (i32 (i32, i32, i32, i8*, i32)* @setsockopt to i8*), i8* bitcast (i8* (i64*)* @ctime to i8*), i8* bitcast (i32 (i8*, ...)* @printf to i8*), i8* bitcast (i32 (i8*, i64, i8*, ...)* @snprintf to i8*), i8* bitcast (i32 (i32, i64, ...)* @ioctl to i8*), i8* bitcast (i64 (i32, i8*, i64)* @read to i8*), i8* bitcast (i32 (%struct._IO_FILE*, i8*, ...)* @fprintf to i8*), i8* bitcast (i64 (i64*)* @time to i8*), i8* bitcast (i32 (i32, %struct.fd_set*, %struct.fd_set*, %struct.fd_set*, %struct.timeval*)* @select to i8*), i8* bitcast (i8* (i64)* @malloc to i8*), i8* bitcast (i32 (i32, %struct.sockaddr*, i32)* @bind to i8*), i8* bitcast (%struct._IO_FILE* (i8*, i8*)* @fopen to i8*), i8* bitcast (void (i8*)* @perror to i8*), i8* bitcast (i32 (i32)* @sleep to i8*), i8* bitcast (i32 (i32, i32, i32)* @socket to i8*), i8* bitcast (i32 (i32, i8**)* @main to i8*), i8* bitcast (i32 (i32*, i8*)* @init_can to i8*), i8* bitcast (void (i8*, %struct.Bumper*)* @rx_brake_routine to i8*), i8* bitcast (void (i8*, %struct.Bumper*)* @rx_signal_routine to i8*), i8* bitcast (void (%struct.Bumper*)* @init_bumper to i8*), i8* bitcast (void (%struct.Bumper*)* @turn_signal_routine to i8*), i8* bitcast (void (%struct.Bumper*)* @brake_routine to i8*), i8* bitcast (void (...)* @initialize_pins to i8*), i8* bitcast (void (i32, i32)* @set_power to i8*), i8* bitcast (void (i32, i8*, i8)* @set_period to i8*), i8* bitcast (void (i32, i32)* @set_duty to i8*)], section "llvm.metadata"

; Function Attrs: noinline
declare x86_64_sysvcc i32 @main(i32, i8**) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @printf(i8*, ...) #0

; Function Attrs: noinline
declare x86_64_sysvcc %struct._IO_FILE* @fopen(i8*, i8*) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @snprintf(i8*, i64, i8*, ...) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @socket(i32, i32, i32) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @init_can(i32*, i8*) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @sleep(i32) #0

; Function Attrs: noinline
declare x86_64_sysvcc void @initialize_pins(...) #0

; Function Attrs: noinline
declare x86_64_sysvcc void @set_period(i32, i8*, i8) #0

; Function Attrs: noinline
declare x86_64_sysvcc void @set_duty(i32, i32) #0

; Function Attrs: noinline
declare x86_64_sysvcc void @set_power(i32, i32) #0

; Function Attrs: noinline
declare x86_64_sysvcc i8* @malloc(i64) #0

; Function Attrs: noinline
declare x86_64_sysvcc void @init_bumper(%struct.Bumper*) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @select(i32, %struct.fd_set*, %struct.fd_set*, %struct.fd_set*, %struct.timeval*) #0

; Function Attrs: noinline
declare x86_64_sysvcc i64 @read(i32, i8*, i64) #0

; Function Attrs: noinline
declare x86_64_sysvcc void @perror(i8*) #0

; Function Attrs: noinline
declare x86_64_sysvcc i64 @time(i64*) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @fprintf(%struct._IO_FILE*, i8*, ...) #0

; Function Attrs: noinline
declare x86_64_sysvcc i8* @ctime(i64*) #0

; Function Attrs: noinline
define x86_64_sysvcc void @rx_brake_routine(i8* %0, %struct.Bumper* %1) #0 {
  %3 = getelementptr %struct.Bumper, %struct.Bumper* %1, i64 0, i32 0
  %4 = getelementptr i8, i8* %0, i64 3
  %5 = load i8, i8* %4, align 1
  %6 = getelementptr i8, i8* %0, i64 2
  %7 = load i8, i8* %6, align 1
  %8 = getelementptr i8, i8* %0, i64 4
  %9 = load i8, i8* %8, align 1
  %10 = and i8 %9, 12
  %11 = icmp ne i8 %10, 0
  %12 = getelementptr i8, i8* %3, i64 5
  %13 = zext i1 %11 to i8
  store i8 %13, i8* %12, align 1
  br i1 %11, label %17, label %14

14:                                               ; preds = %2
  %15 = getelementptr i8, i8* %3, i64 6
  store i8 0, i8* %15, align 1
  %16 = getelementptr i8, i8* %3, i64 4
  store i8 0, i8* %16, align 1
  br label %29

17:                                               ; preds = %2
  %18 = zext i8 %5 to i16
  %19 = shl nuw i16 %18, 8
  %20 = zext i8 %7 to i16
  %21 = or i16 %19, %20
  %22 = icmp slt i16 %21, 1
  br i1 %22, label %29, label %23

23:                                               ; preds = %17
  %24 = getelementptr i8, i8* %3, i64 4
  %25 = load i8, i8* %24, align 1
  %26 = icmp eq i8 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %23
  %28 = getelementptr i8, i8* %3, i64 6
  store i8 1, i8* %28, align 1
  br label %29

29:                                               ; preds = %17, %23, %27, %14
  ret void
}

; Function Attrs: noinline
declare x86_64_sysvcc void @rx_signal_routine(i8*, %struct.Bumper*) #0

; Function Attrs: noinline
declare x86_64_sysvcc void @turn_signal_routine(%struct.Bumper*) #0

; Function Attrs: noinline
declare x86_64_sysvcc void @brake_routine(%struct.Bumper*) #0

; Function Attrs: noinline
declare x86_64_sysvcc i8* @strcpy(i8*, i8*) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @ioctl(i32, i64, ...) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @setsockopt(i32, i32, i32, i8*, i32) #0

; Function Attrs: noinline
declare x86_64_sysvcc i32 @bind(i32, %struct.sockaddr*, i32) #0

attributes #0 = { noinline }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 12.0.0 (https://github.com/trailofbits/vcpkg.git 4592a93cc4ca82f1963dba08413c43639662d7ae)"}

unsigned char __anvill_sp;
unsigned char __anvill_ra;
unsigned int main(unsigned int arg0, unsigned char **arg1);
unsigned int printf(unsigned char *arg0, ...);
struct struct__IO_marker {
};
struct struct__IO_codecvt {
};
struct struct__IO_wide_data {
};
struct struct__IO_FILE {
    unsigned int field0;
    unsigned char *field1;
    unsigned char *field2;
    unsigned char *field3;
    unsigned char *field4;
    unsigned char *field5;
    unsigned char *field6;
    unsigned char *field7;
    unsigned char *field8;
    unsigned char *field9;
    unsigned char *field10;
    unsigned char *field11;
    struct struct__IO_marker *field12;
    struct struct__IO_FILE *field13;
    unsigned int field14;
    unsigned int field15;
    unsigned long field16;
    unsigned short field17;
    unsigned char field18;
    unsigned char field19[1];
    unsigned char *field20;
    unsigned long field21;
    struct struct__IO_codecvt *field22;
    struct struct__IO_wide_data *field23;
    struct struct__IO_FILE *field24;
    unsigned char *field25;
    unsigned long field26;
    unsigned int field27;
    unsigned char field28[20];
};
struct struct__IO_FILE *fopen(unsigned char *arg0, unsigned char *arg1);
unsigned int snprintf(unsigned char *arg0, unsigned long arg1, unsigned char *arg2, ...);
unsigned int socket(unsigned int arg0, unsigned int arg1, unsigned int arg2);
unsigned int init_can(unsigned int *arg0, unsigned char *arg1);
unsigned int sleep(unsigned int arg0);
void initialize_pins(...);
void set_period(unsigned int arg0, unsigned char *arg1, unsigned char arg2);
void set_duty(unsigned int arg0, unsigned int arg1);
void set_power(unsigned int arg0, unsigned int arg1);
unsigned char *malloc(unsigned long arg0);
struct struct_Bumper {
    unsigned char field0;
    unsigned char field1;
    unsigned char field2;
    unsigned char field3;
    unsigned char field4;
    unsigned char field5;
    unsigned char field6;
    unsigned char field7;
    unsigned char field8;
    unsigned char field9;
    unsigned char field10;
    unsigned char field11;
    unsigned long field12;
    unsigned long field13;
};
void init_bumper(struct struct_Bumper *arg0);
struct struct_fd_set {
    unsigned long field0[16];
};
struct struct_timeval {
    unsigned long field0;
    unsigned long field1;
};
unsigned int select(unsigned int arg0, struct struct_fd_set *arg1, struct struct_fd_set *arg2, struct struct_fd_set *arg3, struct struct_timeval *arg4);
unsigned long read(unsigned int arg0, unsigned char *arg1, unsigned long arg2);
void perror(unsigned char *arg0);
unsigned long time(unsigned long *arg0);
unsigned int fprintf(struct struct__IO_FILE *arg0, unsigned char *arg1, ...);
unsigned char *ctime(unsigned long *arg0);
void rx_brake_routine(unsigned char *arg0, struct struct_Bumper *arg1);
void rx_signal_routine(unsigned char *arg0, struct struct_Bumper *arg1);
void turn_signal_routine(struct struct_Bumper *arg0);
void brake_routine(struct struct_Bumper *arg0);
unsigned char *strcpy(unsigned char *arg0, unsigned char *arg1);
unsigned int ioctl(unsigned int arg0, unsigned long arg1, ...);
unsigned int setsockopt(unsigned int arg0, unsigned int arg1, unsigned int arg2, unsigned char *arg3, unsigned int arg4);
struct struct_sockaddr {
    unsigned short field0;
    unsigned char field1[14];
};
unsigned int bind(unsigned int arg0, struct struct_sockaddr *arg1, unsigned int arg2);
void rx_brake_routine(unsigned char *arg0, struct struct_Bumper *arg1) {
    if (1U) {
        return;
    }
}

pgoodman avatar Jun 23 '21 16:06 pgoodman

--remove_phi_nodes and --lower_switch were used.

pgoodman avatar Jun 23 '21 16:06 pgoodman