#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 bootcf();
int /*<<< orphan*/ execve(char *, char **, char **);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[], char *envp[]) {
  int r = bootcf();
  if (r == 0) {
    printf("call init!\n");
    execve("/sbin/init", argv, envp);
  } else {
    printf("FAILED! code: %d. Boot JFFS from FLASH\n", r);
    execve("/bin/initflash", argv, envp);
  }
  perror("Panic! Could not boot anything");
  return 1;
}


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)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1060 <bootcf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1195 <main+0x55>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe81(%rip),%rdi
call   1040 <execve@plt>
jmp    11ba <main+0x7a>
mov    -0x1c(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe8a(%rip),%rdi
call   1040 <execve@plt>
lea    0xe8d(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
xor    %eax,%eax
call   1070 <bootcf@plt>
test   %eax,%eax
jne    117a <main+0x2a>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe88(%rip),%rdi
jmp    1191 <main+0x41>
lea    0xe8a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <execve@plt>
lea    0xe9f(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"call init!\0A\00"
@.str.1 = [11 x i8] c"/sbin/init\00"
@.str.2 = [40 x i8] c"FAILED! code: %d. Boot JFFS from FLASH\0A\00"
@.str.3 = [15 x i8] c"/bin/initflash\00"
@.str.4 = [31 x i8] c"Panic! Could not boot anything\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = call i32 (...) @bootcf()
store i32 %9, i32* %8
%10 = load i32, i32* %8
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = load i8**, i8*** %6
%15 = load i8**, i8*** %7
%16 = call i32 @execve(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %14, i8** %15)
br label %23
17: ; preds = %3
%18 = load i32, i32* %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i8**, i8*** %6
%21 = load i8**, i8*** %7
%22 = call i32 @execve(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8** %20, i8** %21)
br label %23
23: ; preds = %17, %12
%24 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"/sbin/init\00"
@.str.2 = [40 x i8] c"FAILED! code: %d. Boot JFFS from FLASH\0A\00"
@.str.3 = [15 x i8] c"/bin/initflash\00"
@.str.4 = [31 x i8] c"Panic! Could not boot anything\00"
@str = [11 x i8] c"call init!\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = tail call i32 (...) @bootcf()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %10
8: ; preds = %3
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %4)
br label %10
10: ; preds = %8, %6
%11 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %8 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %6 ]
%12 = tail call i32 @execve(i8* %11, i8** %1, i8** %2)
%13 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
ret i32 1
}