#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 */

/* Variables and functions */
int /*<<< orphan*/ Err_put(char *, int);
int /*<<< orphan*/ Info_put(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ log_close();
scalar_t__ log_open(char *);
int /*<<< orphan*/ stderr;
int main() {
  if (log_open("./log")) {
    fprintf(stderr, "Fail to open log file %s\n", "./log");
    return 0;
  }
  Info_put("look, world %d\n", 10);
  ;
  Err_put("look, world %d\n", 12);
  log_close();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <log_open@plt>
cmp    $0x0,%rax
je     119d <main+0x4d>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
lea    0xe74(%rip),%rdx
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cd <main+0x7d>
lea    0xe7c(%rip),%rdi
mov    $0xa,%esi
call   1070 <Info_put@plt>
lea    0xe6b(%rip),%rdi
mov    $0xc,%esi
call   1040 <Err_put@plt>
mov    $0x0,%al
call   1060 <log_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1030 <log_open@plt>
test   %rax,%rax
je     1180 <main+0x30>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
lea    0xe87(%rip),%rdx
call   1050 <fprintf@plt>
jmp    11a8 <main+0x58>
lea    0xe99(%rip),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <Info_put@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
call   1040 <Err_put@plt>
xor    %eax,%eax
call   1060 <log_close@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"./log\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Fail to open log file %s\0A\00"
@.str.2 = [16 x i8] c"look, world %d\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 @log_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %11
7: ; preds = %0
%8 = call i32 @Info_put(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 10)
%9 = call i32 @Err_put(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 12)
%10 = call i32 (...) @log_close()
store i32 0, i32* %1
br label %11
11: ; preds = %7, %4
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@.str = [6 x i8] c"./log\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Fail to open log file %s\0A\00"
@.str.2 = [16 x i8] c"look, world %d\0A\00"
define i32 @main() {
%1 = tail call i64 @log_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %10
6: ; preds = %0
%7 = tail call i32 @Info_put(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 10)
%8 = tail call i32 @Err_put(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 12)
%9 = tail call i32 (...) @log_close()
br label %10
10: ; preds = %6, %3
ret i32 0
}