#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*/ diskio_write_exit();
scalar_t__ diskio_write_setopt(char *, char *);
scalar_t__ diskio_write_test(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ *grideye_plugin_init_v2(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char *f;
  char *str = NULL;
  if (argc != 3) {
    fprintf(stderr, "usage %s <file> <bytes>\n", argv[0]);
    return -1;
  }
  f = argv[1];
  if (grideye_plugin_init_v2(2) == NULL)
    return -1;
  if (diskio_write_setopt("writefile", f) < 0)
    return -1;
  if (diskio_write_test(argv[2], &str) < 0)
    return -1;
  fprintf(stdout, "%s\n", str);
  free(str);
  diskio_write_exit();
  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)
movq   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11b0 <main+0x50>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe61(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1259 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    $0x2,%edi
call   1060 <grideye_plugin_init_v2@plt>
cmp    $0x0,%rax
jne    11dc <main+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1259 <main+0xf9>
mov    -0x18(%rbp),%rsi
lea    0xe32(%rip),%rdi
call   1050 <diskio_write_setopt@plt>
cmp    $0x0,%rax
jge    1202 <main+0xa2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1259 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <diskio_write_test@plt>
cmp    $0x0,%rax
jge    1229 <main+0xc9>
movl   $0xffffffff,-0x4(%rbp)
jmp    1259 <main+0xf9>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xde6(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1040 <diskio_write_exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movq   $0x0,0x8(%rsp)
cmp    $0x3,%edi
jne    11e7 <main+0x87>
mov    0x8(%rbx),%r14
mov    $0x2,%edi
call   1060 <grideye_plugin_init_v2@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1204 <main+0xa4>
lea    0xe81(%rip),%rdi
mov    %r14,%rsi
call   1050 <diskio_write_setopt@plt>
test   %rax,%rax
js     1204 <main+0xa4>
mov    0x10(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1080 <diskio_write_test@plt>
test   %rax,%rax
js     1204 <main+0xa4>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rdx
lea    0xe56(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <diskio_write_exit@plt>
jmp    1204 <main+0xa4>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe06(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"usage %s <file> <bytes>\0A\00"
@.str.1 = [10 x i8] c"writefile\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 -1, i32* %3
br label %42
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %6
%20 = call i32* @grideye_plugin_init_v2(i32 2)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 -1, i32* %3
br label %42
23: ; preds = %16
%24 = load i8*, i8** %6
%25 = call i64 @diskio_write_setopt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 -1, i32* %3
br label %42
28: ; preds = %23
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i64 @diskio_write_test(i8* %31, i8** %7)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %28
store i32 -1, i32* %3
br label %42
35: ; preds = %28
%36 = load i32, i32* @stdout
%37 = load i8*, i8** %7
%38 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %7
%40 = call i32 @free(i8* %39)
%41 = call i32 (...) @diskio_write_exit()
store i32 0, i32* %3
br label %42
42: ; preds = %35, %34, %27, %22, %10
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"usage %s <file> <bytes>\0A\00"
@.str.1 = [10 x i8] c"writefile\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp eq i32 %0, 3
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %30
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @grideye_plugin_init_v2(i32 2)
%14 = icmp eq i32* %13, null
br i1 %14, label %30, label %15
15: ; preds = %10
%16 = tail call i64 @diskio_write_setopt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%17 = icmp slt i64 %16, 0
br i1 %17, label %30, label %18
18: ; preds = %15
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = call i64 @diskio_write_test(i8* %20, i8** %3)
%22 = icmp slt i64 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %18
%24 = load i32, i32* @stdout
%25 = load i8*, i8** %3
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %3
%28 = call i32 @free(i8* %27)
%29 = call i32 (...) @diskio_write_exit()
br label %30
30: ; preds = %18, %15, %10, %23, %6
%31 = phi i32 [ -1, %6 ], [ 0, %23 ], [ -1, %10 ], [ -1, %15 ], [ -1, %18 ]
ret i32 %31
}