#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  if (!argv[1]) {
    printf("usage: %s <device>\n\n", argv[0]);
    printf(
        "NOTE: Don't run this on a partition. Use it on the device itself.\n");
    printf("The AIX System Team is not responable for any damage done to your "
           "computer or storage devices\n");
    printf("by incorrect usage of this tool.\n");
    exit(-1);
  }
  printf(
      "%s: Creating a Bootable Hilix Computer to your USB STICK (device=%s)\n",
      argv[0], argv[1]);
  printf("%s: Building the floppy image to the USB Stick.", argv[0]);
  system("cd ..;make floppy");
  char *syscmd;
  sprintf(syscmd, "cd ..;dd if=build/kernel.bin of=%s", argv[1]);
  printf("%s: Copying image to device with dd.", argv[0]);
  system(syscmd);
  printf("%s: Done.\n", argv[0]);
  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)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    11ae <main+0x6e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xf15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xf46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf68(%rip),%rdi
call   1030 <system@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xf62(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xf72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <system@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xf79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
mov    (%rsi),%rsi
mov    0x8(%rbx),%rdx
test   %rdx,%rdx
je     11c6 <main+0x76>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rsi
lea    0xee3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf05(%rip),%rdi
call   1040 <system@plt>
mov    0x8(%rbx),%rdx
lea    0xf07(%rip),%rsi
call   1060 <sprintf@plt>
mov    (%rbx),%rsi
lea    0xf1b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
call   1040 <system@plt>
mov    (%rbx),%rsi
lea    0xf2a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf9d(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"usage: %s <device>\0A\0A\00"
@.str.1 = [67 x i8] c"NOTE: Don't run this on a partition. Use it on the device itself.\0A\00"
@.str.2 = [95 x i8] c"The AIX System Team is not responable for any damage done to your computer or storage devices\0A\00"
@.str.3 = [34 x i8] c"by incorrect usage of this tool.\0A\00"
@.str.4 = [70 x i8] c"%s: Creating a Bootable Hilix Computer to your USB STICK (device=%s)\0A\00"
@.str.5 = [48 x i8] c"%s: Building the floppy image to the USB Stick.\00"
@.str.6 = [18 x i8] c"cd ..;make floppy\00"
@.str.7 = [35 x i8] c"cd ..;dd if=build/kernel.bin of=%s\00"
@.str.8 = [37 x i8] c"%s: Copying image to device with dd.\00"
@.str.9 = [11 x i8] c"%s: Done.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %20, label %11
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0), i8* %23, i8* %26)
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* %30)
%32 = call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%33 = load i8*, i8** %6
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8* %36)
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %40)
%42 = load i8*, i8** %6
%43 = call i32 @system(i8* %42)
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"usage: %s <device>\0A\0A\00"
@.str.4 = [70 x i8] c"%s: Creating a Bootable Hilix Computer to your USB STICK (device=%s)\0A\00"
@.str.5 = [48 x i8] c"%s: Building the floppy image to the USB Stick.\00"
@.str.6 = [18 x i8] c"cd ..;make floppy\00"
@.str.7 = [35 x i8] c"cd ..;dd if=build/kernel.bin of=%s\00"
@.str.8 = [37 x i8] c"%s: Copying image to device with dd.\00"
@.str.9 = [11 x i8] c"%s: Done.\0A\00"
@str = [66 x i8] c"NOTE: Don't run this on a partition. Use it on the device itself.\00"
@str.10 = [94 x i8] c"The AIX System Team is not responable for any damage done to your computer or storage devices\00"
@str.11 = [33 x i8] c"by incorrect usage of this tool.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
%6 = load i8*, i8** %1
br i1 %5, label %7, label %13
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %6)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 x i8]* @str.10, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.11, i64 0, i64 0))
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0), i8* %6, i8* %4)
%15 = load i8*, i8** %1
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* %15)
%17 = tail call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%18 = load i8*, i8** %3
%19 = tail call i32 @sprintf(i8* dereferenceable(1) undef, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %1
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %20)
%22 = tail call i32 @system(i8* undef)
%23 = load i8*, i8** %1
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %23)
ret i32 0
}