#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*/ Log(char *);
scalar_t__ do_work(int, char *);
scalar_t__ setup_signals();
int start_server();
int main(int argc, char *argv[]) {
  Log("Program initialized");
  char *device;
  device = "/dev/graphics/fb0";
  int server_socket = start_server();
  if (server_socket < 0)
    Log("Error while starting server");
  if (setup_signals() < 0)
    Log("Error while setting up signals");
  if (do_work(server_socket, device) < 0)
    Log("Error in main loop");
}


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)
lea    0xea3(%rip),%rdi
call   1050 <Log@plt>
lea    0xeab(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <start_server@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    118d <main+0x4d>
lea    0xe9e(%rip),%rdi
call   1050 <Log@plt>
mov    $0x0,%al
call   1040 <setup_signals@plt>
cmp    $0x0,%rax
jge    11aa <main+0x6a>
lea    0xe9d(%rip),%rdi
call   1050 <Log@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <do_work@plt>
cmp    $0x0,%rax
jge    11cc <main+0x8c>
lea    0xe9a(%rip),%rdi
call   1050 <Log@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1050 <Log@plt>
xor    %eax,%eax
call   1060 <start_server@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1166 <main+0x26>
lea    0xec5(%rip),%rdi
call   1050 <Log@plt>
xor    %eax,%eax
call   1040 <setup_signals@plt>
test   %rax,%rax
jns    117e <main+0x3e>
lea    0xec9(%rip),%rdi
call   1050 <Log@plt>
lea    0xe8f(%rip),%rsi
mov    %ebx,%edi
call   1030 <do_work@plt>
test   %rax,%rax
jns    119d <main+0x5d>
lea    0xec9(%rip),%rdi
call   1050 <Log@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Program initialized\00"
@.str.1 = [18 x i8] c"/dev/graphics/fb0\00"
@.str.2 = [28 x i8] c"Error while starting server\00"
@.str.3 = [31 x i8] c"Error while setting up signals\00"
@.str.4 = [19 x i8] c"Error in main loop\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @Log(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %6
%9 = call i32 (...) @start_server()
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @Log(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %2
%15 = call i64 (...) @setup_signals()
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @Log(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
%20 = load i32, i32* %7
%21 = load i8*, i8** %6
%22 = call i64 @do_work(i32 %20, i8* %21)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 @Log(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %26
26: ; preds = %24, %19
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [20 x i8] c"Program initialized\00"
@.str.1 = [18 x i8] c"/dev/graphics/fb0\00"
@.str.2 = [28 x i8] c"Error while starting server\00"
@.str.3 = [31 x i8] c"Error while setting up signals\00"
@.str.4 = [19 x i8] c"Error in main loop\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @Log(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @start_server()
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @Log(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = tail call i64 (...) @setup_signals()
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @Log(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = tail call i64 @do_work(i32 %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @Log(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
ret i32 0
}