#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(int /*<<< orphan*/, 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(int, char *, int, char *);
int /*<<< orphan*/ zlogf(int, char *, ...);
int /*<<< orphan*/ zlogf_time(int, char *);
int main(int argc, char *argv[]) {
  int i = 0;
  zlog_init_stdout();
  zlog_init_flush_thread();
  zlogf_time(1, "zlog is initialized (debug)\n");
  zlogf_time(0, "zlog is initialized (info)\n");
  zlogf(0, "Command line: \n");
  for (i = 0; i < argc; i++) {
    zlogf(0, "argv[%d]: %s \n", i, argv[i]);
    zlogf(1, "(DEBUG) argv[%d]: %s \n", i, argv[i]);
  }
  zlogf(0, "\n\n");
  zlogf_time(0, "I flush the buffer explicitly.\n");
  zlogf(0, "This is just a ## [+] debug message [+] ##\n");
  zlog_flush_buffer();
  zlog_time(0,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/zma/zlog/refs/heads/master/example.c",
            50, "Log with file and line. TIMESTAMPED.\n");
  zlog_time(1,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/zma/zlog/refs/heads/master/example.c",
            51, "(DEBUG) Log with file and line. TIMESTAMPED.\n");
  zlog(0,
       "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
       "2022-01-22/02-19-57/repos/zma/zlog/refs/heads/master/example.c",
       54, "Log with file and line. NO TIMESTAMP.\n");
  printf("FOR TEST: I will sleep for 200 seconds... Please be patient.\n");
  sleep(200);
  zlogf_time(0, "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>
mov    $0x1,%edi
lea    0xe29(%rip),%rsi
call   10c0 <zlogf_time@plt>
xor    %edi,%edi
lea    0xe38(%rip),%rsi
call   10c0 <zlogf_time@plt>
xor    %edi,%edi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1030 <zlogf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    125c <main+0xbc>
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
xor    %edi,%edi
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1030 <zlogf@plt>
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    $0x1,%edi
lea    0xe02(%rip),%rsi
mov    $0x0,%al
call   1030 <zlogf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1201 <main+0x61>
xor    %edi,%edi
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1030 <zlogf@plt>
xor    %edi,%edi
lea    0xdee(%rip),%rsi
call   10c0 <zlogf_time@plt>
xor    %edi,%edi
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1030 <zlogf@plt>
mov    $0x0,%al
call   1060 <zlog_flush_buffer@plt>
xor    %edi,%edi
lea    0xe15(%rip),%rsi
mov    $0x32,%edx
lea    0xe90(%rip),%rcx
call   1050 <zlog_time@plt>
mov    $0x1,%edi
lea    0xdf8(%rip),%rsi
mov    $0x33,%edx
lea    0xe6b(%rip),%rcx
call   1050 <zlog_time@plt>
xor    %edi,%edi
lea    0xdde(%rip),%rsi
mov    $0x36,%edx
lea    0xe7f(%rip),%rcx
call   1090 <zlog@plt>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
mov    $0xc8,%edi
call   10a0 <sleep@plt>
xor    %edi,%edi
lea    0xec0(%rip),%rsi
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   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <zlog_init_stdout@plt>
xor    %eax,%eax
call   10b0 <zlog_init_flush_thread@plt>
lea    0xe3e(%rip),%rsi
mov    $0x1,%edi
call   10c0 <zlogf_time@plt>
lea    0xe4a(%rip),%rsi
xor    %edi,%edi
call   10c0 <zlogf_time@plt>
lea    0xe58(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1040 <zlogf@plt>
test   %ebp,%ebp
jle    1240 <main+0xa0>
mov    %ebp,%r12d
lea    0xe59(%rip),%r14
lea    0xe4a(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rcx
xor    %edi,%edi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <zlogf@plt>
mov    (%rbx,%rbp,8),%rcx
mov    $0x1,%edi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <zlogf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1210 <main+0x70>
lea    0xe19(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1040 <zlogf@plt>
lea    0xe0c(%rip),%rsi
xor    %edi,%edi
call   10c0 <zlogf_time@plt>
lea    0xe1e(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1040 <zlogf@plt>
xor    %eax,%eax
call   1060 <zlog_flush_buffer@plt>
lea    0xe33(%rip),%rbx
lea    0xeb3(%rip),%rcx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x32,%edx
call   1050 <zlog_time@plt>
lea    0xe95(%rip),%rcx
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x33,%edx
call   1050 <zlog_time@plt>
lea    0xeaa(%rip),%rcx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x36,%edx
call   1090 <zlog@plt>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
mov    $0xc8,%edi
call   10a0 <sleep@plt>
lea    0xea5(%rip),%rsi
xor    %edi,%edi
call   10c0 <zlogf_time@plt>
xor    %eax,%eax
call   1080 <zlog_finish@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"zlog is initialized (debug)\0A\00"
@.str.1 = [28 x i8] c"zlog is initialized (info)\0A\00"
@.str.2 = [16 x i8] c"Command line: \0A\00"
@.str.3 = [15 x i8] c"argv[%d]: %s \0A\00"
@.str.4 = [23 x i8] c"(DEBUG) argv[%d]: %s \0A\00"
@.str.5 = [3 x i8] c"\0A\0A\00"
@.str.6 = [32 x i8] c"I flush the buffer explicitly.\0A\00"
@.str.7 = [44 x i8] c"This is just a ## [+] debug message [+] ##\0A\00"
@.str.8 = [127 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zma/zlog/refs/heads/master/example.c\00"
@.str.9 = [38 x i8] c"Log with file and line. TIMESTAMPED.\0A\00"
@.str.10 = [46 x i8] c"(DEBUG) Log with file and line. TIMESTAMPED.\0A\00"
@.str.11 = [39 x i8] c"Log with file and line. NO TIMESTAMP.\0A\00"
@.str.12 = [62 x i8] c"FOR TEST: I will sleep for 200 seconds... Please be patient.\0A\00"
@.str.13 = [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(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @zlogf_time(i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i32, i8*, ...) @zlogf(i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %12
12: ; preds = %31, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %34
16: ; preds = %12
%17 = load i32, i32* %6
%18 = load i8**, i8*** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @zlogf(i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %17, i8* %22)
%24 = load i32, i32* %6
%25 = load i8**, i8*** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 (i32, i8*, ...) @zlogf(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %24, i8* %29)
br label %31
31: ; preds = %16
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %12
34: ; preds = %12
%35 = call i32 (i32, i8*, ...) @zlogf(i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%36 = call i32 @zlogf_time(i32 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 (i32, i8*, ...) @zlogf(i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
%38 = call i32 (...) @zlog_flush_buffer()
%39 = call i32 @zlog_time(i32 0, i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.8, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
%40 = call i32 @zlog_time(i32 1, i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.8, i64 0, i64 0), i32 51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.10, i64 0, i64 0))
%41 = call i32 @zlog(i32 0, i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.8, i64 0, i64 0), i32 54, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0))
%42 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.12, i64 0, i64 0))
%43 = call i32 @sleep(i32 200)
%44 = call i32 @zlogf_time(i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
%45 = call i32 (...) @zlog_finish()
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"zlog is initialized (debug)\0A\00"
@.str.1 = [28 x i8] c"zlog is initialized (info)\0A\00"
@.str.2 = [16 x i8] c"Command line: \0A\00"
@.str.3 = [15 x i8] c"argv[%d]: %s \0A\00"
@.str.4 = [23 x i8] c"(DEBUG) argv[%d]: %s \0A\00"
@.str.5 = [3 x i8] c"\0A\0A\00"
@.str.6 = [32 x i8] c"I flush the buffer explicitly.\0A\00"
@.str.7 = [44 x i8] c"This is just a ## [+] debug message [+] ##\0A\00"
@.str.8 = [127 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zma/zlog/refs/heads/master/example.c\00"
@.str.9 = [38 x i8] c"Log with file and line. TIMESTAMPED.\0A\00"
@.str.10 = [46 x i8] c"(DEBUG) Log with file and line. TIMESTAMPED.\0A\00"
@.str.11 = [39 x i8] c"Log with file and line. NO TIMESTAMP.\0A\00"
@.str.13 = [19 x i8] c"finish using zlog\0A\00"
@str = [61 x i8] c"FOR TEST: I will sleep for 200 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(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @zlogf_time(i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 (i32, i8*, ...) @zlogf(i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %19, %11 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = trunc i64 %12 to i32
%16 = tail call i32 (i32, i8*, ...) @zlogf(i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %15, i8* %14)
%17 = load i8*, i8** %13
%18 = tail call i32 (i32, i8*, ...) @zlogf(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %15, i8* %17)
%19 = add nuw nsw i64 %12, 1
%20 = icmp eq i64 %19, %10
br i1 %20, label %21, label %11
21: ; preds = %11, %2
%22 = tail call i32 (i32, i8*, ...) @zlogf(i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%23 = tail call i32 @zlogf_time(i32 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%24 = tail call i32 (i32, i8*, ...) @zlogf(i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
%25 = tail call i32 (...) @zlog_flush_buffer()
%26 = tail call i32 @zlog_time(i32 0, i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.8, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
%27 = tail call i32 @zlog_time(i32 1, i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.8, i64 0, i64 0), i32 51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.10, i64 0, i64 0))
%28 = tail call i32 @zlog(i32 0, i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.8, i64 0, i64 0), i32 54, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%30 = tail call i32 @sleep(i32 200)
%31 = tail call i32 @zlogf_time(i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
%32 = tail call i32 (...) @zlog_finish()
ret i32 0
}