#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ usleep(int);
void read_config() {
  int success = 0;
  while (!success) {
    FILE *fp;
    fp = fopen("/etc/tracing-server-example.conf", "r");
    if (fp) {
      success = 1;
      printf("[*] Read configuration successfully.\n");
      fclose(fp);
    } else {
      usleep(1);
    }
  }
}


x86 assembly (clang, -O0):
<read_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1165 <read_config+0x25>
jmp    11b7 <read_config+0x77>
lea    0xe94(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a8 <read_config+0x68>
movl   $0x1,-0x4(%rbp)
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11b2 <read_config+0x72>
mov    $0x1,%edi
call   1060 <usleep@plt>
jmp    114f <read_config+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_config>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
lea    0xece(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    118d <read_config+0x4d>
lea    0xe99(%rip),%r14
lea    0xeb3(%rip),%r15
xchg   %ax,%ax
mov    $0x1,%edi
call   1060 <usleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1170 <read_config+0x30>
mov    %rax,%rbx
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"/etc/tracing-server-example.conf\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [38 x i8] c"[*] Read configuration successfully.\0A\00"
define void @read_config() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
br label %3
3: ; preds = %17, %0
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, 0
%6 = xor i1 %5, true
br i1 %6, label %7, label %18
7: ; preds = %3
%8 = call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %7
store i32 1, i32* %1
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32*, i32** %2
%14 = call i32 @fclose(i32* %13)
br label %17
15: ; preds = %7
%16 = call i32 @usleep(i32 1)
br label %17
17: ; preds = %15, %11
br label %3
18: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"/etc/tracing-server-example.conf\00"
@.str.1 = [2 x i8] c"r\00"
@str = [37 x i8] c"[*] Read configuration successfully.\00"
define void @read_config() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %7
3: ; preds = %0, %3
%4 = tail call i32 @usleep(i32 1)
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %3, label %7
7: ; preds = %3, %0
%8 = phi i32* [ %1, %0 ], [ %5, %3 ]
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @fclose(i32* %8)
ret void
}