#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*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ zlog(char *, int, char *);
int /*<<< orphan*/ zlog_finish();
int /*<<< orphan*/ zlog_flush_buffer();
int /*<<< orphan*/ zlog_init_flush_thread();
int /*<<< orphan*/ zlog_init_stdout();
int /*<<< orphan*/ zlog_time(char *, int, char *);
int /*<<< orphan*/ zlogf(char *, ...);
int /*<<< orphan*/ zlogf_time(char *);
int main(int argc, char *argv[]) {
  int i = 0;
  zlog_init_stdout();
  zlog_init_flush_thread();
  zlogf_time("zlog is initialized\n");
  zlogf("Command line: \n");
  for (i = 0; i < argc; i++) {
    zlogf("argv[%d]: %s \n", i, argv[i]);
  }
  zlogf("\n\n");
  zlogf_time("I flush the buffer explicitly.\n");
  zlog_flush_buffer();
  zlog_time("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/approximator/FlightGear_S-function/refs/"
            "heads/master/S-Function/Src/third_party/zlog/example.c",
            45, "more logs...\n");
  zlog("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
       "2022-01-22/02-19-57/repos/approximator/FlightGear_S-function/refs/"
       "heads/master/S-Function/Src/third_party/zlog/example.c",
       48, "and more logs...\n");
  printf("FOR TEST: I will sleep for 600 seconds... Please be patient.\n");
  sleep(600);
  zlogf_time("finish using zlog\n");
  zlog_finish();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1070 <zlog_init_stdout@plt>
mov    $0x0,%al
call   10b0 <zlog_init_flush_thread@plt>
lea    0xe2e(%rip),%rdi
call   10c0 <zlogf_time@plt>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <zlogf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1223 <main+0x83>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <zlogf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ec <main+0x4c>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <zlogf@plt>
lea    0xdff(%rip),%rdi
call   10c0 <zlogf_time@plt>
mov    $0x0,%al
call   1060 <zlog_flush_buffer@plt>
lea    0xe0c(%rip),%rdi
mov    $0x2d,%esi
lea    0xebd(%rip),%rdx
call   1050 <zlog_time@plt>
lea    0xdf4(%rip),%rdi
mov    $0x30,%esi
lea    0xea1(%rip),%rdx
call   1090 <zlog@plt>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
mov    $0x258,%edi
call   10a0 <sleep@plt>
lea    0xecf(%rip),%rdi
call   10c0 <zlogf_time@plt>
mov    $0x0,%al
call   1080 <zlog_finish@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <zlog_init_stdout@plt>
xor    %eax,%eax
call   10b0 <zlog_init_flush_thread@plt>
lea    0xe3f(%rip),%rdi
call   10c0 <zlogf_time@plt>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1040 <zlogf@plt>
test   %ebp,%ebp
jle    1209 <main+0x69>
mov    %ebp,%ebx
lea    0xe44(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbp,8),%rdx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <zlogf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11f0 <main+0x50>
lea    0xe24(%rip),%rdi
xor    %eax,%eax
call   1040 <zlogf@plt>
lea    0xe19(%rip),%rdi
call   10c0 <zlogf_time@plt>
xor    %eax,%eax
call   1060 <zlog_flush_buffer@plt>
lea    0xe26(%rip),%rbx
lea    0xedc(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1050 <zlog_time@plt>
lea    0xec4(%rip),%rdx
mov    %rbx,%rdi
mov    $0x30,%esi
call   1090 <zlog@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x258,%edi
call   10a0 <sleep@plt>
lea    0xeac(%rip),%rdi
call   10c0 <zlogf_time@plt>
xor    %eax,%eax
call   1080 <zlog_finish@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"zlog is initialized\0A\00"
@.str.1 = [16 x i8] c"Command line: \0A\00"
@.str.2 = [15 x i8] c"argv[%d]: %s \0A\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
@.str.4 = [32 x i8] c"I flush the buffer explicitly.\0A\00"
@.str.5 = [185 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/approximator/FlightGear_S-function/refs/heads/master/S-Function/Src/third_party/zlog/example.c\00"
@.str.6 = [14 x i8] c"more logs...\0A\00"
@.str.7 = [18 x i8] c"and more logs...\0A\00"
@.str.8 = [62 x i8] c"FOR TEST: I will sleep for 600 seconds... Please be patient.\0A\00"
@.str.9 = [19 x i8] c"finish using zlog\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = call i32 (...) @zlog_init_stdout()
%8 = call i32 (...) @zlog_init_flush_thread()
%9 = call i32 @zlogf_time(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @zlogf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %11
11: ; preds = %23, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i32, i32* %6
%17 = load i8**, i8*** %5
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @zlogf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %16, i8* %21)
br label %23
23: ; preds = %15
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %11
26: ; preds = %11
%27 = call i32 (i8*, ...) @zlogf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @zlogf_time(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 (...) @zlog_flush_buffer()
%30 = call i32 @zlog_time(i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str.5, i64 0, i64 0), i32 45, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%31 = call i32 @zlog(i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str.5, i64 0, i64 0), i32 48, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%32 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.8, i64 0, i64 0))
%33 = call i32 @sleep(i32 600)
%34 = call i32 @zlogf_time(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%35 = call i32 (...) @zlog_finish()
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"zlog is initialized\0A\00"
@.str.1 = [16 x i8] c"Command line: \0A\00"
@.str.2 = [15 x i8] c"argv[%d]: %s \0A\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
@.str.4 = [32 x i8] c"I flush the buffer explicitly.\0A\00"
@.str.5 = [185 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/approximator/FlightGear_S-function/refs/heads/master/S-Function/Src/third_party/zlog/example.c\00"
@.str.6 = [14 x i8] c"more logs...\0A\00"
@.str.7 = [18 x i8] c"and more logs...\0A\00"
@.str.9 = [19 x i8] c"finish using zlog\0A\00"
@str = [61 x i8] c"FOR TEST: I will sleep for 600 seconds... Please be patient.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @zlog_init_stdout()
%4 = tail call i32 (...) @zlog_init_flush_thread()
%5 = tail call i32 @zlogf_time(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @zlogf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %16, %10 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = trunc i64 %11 to i32
%15 = tail call i32 (i8*, ...) @zlogf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %14, i8* %13)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %18, label %10
18: ; preds = %10, %2
%19 = tail call i32 (i8*, ...) @zlogf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 @zlogf_time(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%21 = tail call i32 (...) @zlog_flush_buffer()
%22 = tail call i32 @zlog_time(i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str.5, i64 0, i64 0), i32 45, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%23 = tail call i32 @zlog(i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str.5, i64 0, i64 0), i32 48, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%25 = tail call i32 @sleep(i32 600)
%26 = tail call i32 @zlogf_time(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%27 = tail call i32 (...) @zlog_finish()
ret i32 0
}