#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct bitis_fileTypeModuleLE {
  int dummy;
};

/* Variables and functions */
char *bitis_GetBuildDate();
struct bitis_fileTypeModuleLE *
bitis_GetModules(struct bitis_fileTypeModuleLE **);
char *bitis_GetVersion();
int /*<<< orphan*/ free(struct bitis_fileTypeModuleLE *);
int /*<<< orphan*/ printf(char *, ...);
int info_worker(int argc, char *argv[]) {
  struct bitis_fileTypeModuleLE *orphans;
  struct bitis_fileTypeModuleLE *list = bitis_GetModules(&orphans);
  printf("Lib Version: %s\n", bitis_GetVersion());
  printf("Lib Build Date: %s\n", bitis_GetBuildDate());
  unsigned char charVal[] = {0x00, 0x00, 0x00, 0x01};
  unsigned int *intVal = (unsigned int *)charVal;
  printf("Architecture: %s\n", (*intVal == 1) ? "Big Endian" : "Little Endian");
  printf("Modules:\n");
  if (orphans) {
    printf("Orphans:\n");
    free(orphans);
  }
  free(list);
  return 0;
}


x86 assembly (clang, -O0):
<info_worker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <bitis_GetModules@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <bitis_GetVersion@plt>
mov    %rax,%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <bitis_GetBuildDate@plt>
mov    %rax,%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0xec2(%rip),%eax
mov    %eax,-0x24(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
lea    0xe88(%rip),%rsi
lea    0xe76(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     1206 <info_worker+0xb6>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<info_worker>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1080 <bitis_GetModules@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <bitis_GetVersion@plt>
lea    0xe80(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1040 <bitis_GetBuildDate@plt>
lea    0xe79(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    0xe87(%rip),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe87(%rip),%rdi
call   1050 <puts@plt>
cmpq   $0x0,0x8(%rsp)
je     11e1 <info_worker+0x81>
lea    0xe7c(%rip),%rdi
call   1050 <puts@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.bitis_fileTypeModuleLE = type { i32 }
@.str = [17 x i8] c"Lib Version: %s\0A\00"
@.str.1 = [20 x i8] c"Lib Build Date: %s\0A\00"
@__const.info_worker.charVal = [4 x i8] c"\00\00\00\01"
@.str.2 = [18 x i8] c"Architecture: %s\0A\00"
@.str.3 = [11 x i8] c"Big Endian\00"
@.str.4 = [14 x i8] c"Little Endian\00"
@.str.5 = [10 x i8] c"Modules:\0A\00"
@.str.6 = [10 x i8] c"Orphans:\0A\00"
define i32 @info_worker(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.bitis_fileTypeModuleLE*
%6 = alloca %struct.bitis_fileTypeModuleLE*
%7 = alloca [4 x i8]
%8 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = call %struct.bitis_fileTypeModuleLE* @bitis_GetModules(%struct.bitis_fileTypeModuleLE** %5)
store %struct.bitis_fileTypeModuleLE* %9, %struct.bitis_fileTypeModuleLE** %6
%10 = call i8* (...) @bitis_GetVersion()
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = call i8* (...) @bitis_GetBuildDate()
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = bitcast [4 x i8]* %7 to i8*
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%16 = bitcast i8* %15 to i32*
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 1
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%24 = load %struct.bitis_fileTypeModuleLE*, %struct.bitis_fileTypeModuleLE** %5
%25 = icmp ne %struct.bitis_fileTypeModuleLE* %24, null
br i1 %25, label %26, label %30
26: ; preds = %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%28 = load %struct.bitis_fileTypeModuleLE*, %struct.bitis_fileTypeModuleLE** %5
%29 = call i32 @free(%struct.bitis_fileTypeModuleLE* %28)
br label %30
30: ; preds = %26, %2
%31 = load %struct.bitis_fileTypeModuleLE*, %struct.bitis_fileTypeModuleLE** %6
%32 = call i32 @free(%struct.bitis_fileTypeModuleLE* %31)
ret i32 0
}

LLVM IR (-O2):
%struct.bitis_fileTypeModuleLE = type { i32 }
@.str = [17 x i8] c"Lib Version: %s\0A\00"
@.str.1 = [20 x i8] c"Lib Build Date: %s\0A\00"
@.str.2 = [18 x i8] c"Architecture: %s\0A\00"
@.str.4 = [14 x i8] c"Little Endian\00"
@str = [9 x i8] c"Modules:\00"
@str.7 = [9 x i8] c"Orphans:\00"
define i32 @info_worker(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.bitis_fileTypeModuleLE*
%4 = bitcast %struct.bitis_fileTypeModuleLE** %3 to i8*
%5 = call %struct.bitis_fileTypeModuleLE* @bitis_GetModules(%struct.bitis_fileTypeModuleLE** %3)
%6 = call i8* (...) @bitis_GetVersion()
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i8* (...) @bitis_GetBuildDate()
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%12 = load %struct.bitis_fileTypeModuleLE*, %struct.bitis_fileTypeModuleLE** %3
%13 = icmp eq %struct.bitis_fileTypeModuleLE* %12, null
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
%16 = load %struct.bitis_fileTypeModuleLE*, %struct.bitis_fileTypeModuleLE** %3
%17 = call i32 @free(%struct.bitis_fileTypeModuleLE* %16)
br label %18
18: ; preds = %14, %2
%19 = call i32 @free(%struct.bitis_fileTypeModuleLE* %5)
ret i32 0
}