#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ atoi(char *);
scalar_t__ file_write(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  if (argc != 4) {
    printf("Usage: %s <filename> <block size in k> <count>\n", argv[0]);
    return EXIT_FAILURE;
  }
  if (file_write(argv[1], atoi(argv[2]), atoi(argv[3])) < 0) {
    perror("write failed");
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


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)
cmpl   $0x4,-0x8(%rbp)
je     1184 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <main+0xae>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    %eax,%edx
call   1060 <file_write@plt>
cmp    $0x0,%rax
jge    11e2 <main+0xa2>
lea    0xe64(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <main+0xae>
mov    0x2def(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    117e <main+0x3e>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   1050 <atoi@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1060 <file_write@plt>
test   %rax,%rax
js     119b <main+0x5b>
mov    0x2e5c(%rip),%rax
jmp    1194 <main+0x54>
mov    (%rbx),%rsi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe8e(%rip),%rdi
call   1040 <perror@plt>
jmp    118d <main+0x4d>

LLVM IR (-O0):
@.str = [48 x i8] c"Usage: %s <filename> <block size in k> <count>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [13 x i8] c"write failed\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 4
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %33
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 3
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
%26 = call i64 @file_write(i8* %17, i32 %21, i32 %25)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %14
%29 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %33
31: ; preds = %14
%32 = load i32, i32* @EXIT_SUCCESS
store i32 %32, i32* %3
br label %33
33: ; preds = %31, %28, %8
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [48 x i8] c"Usage: %s <filename> <block size in k> <count>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [13 x i8] c"write failed\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %20
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = tail call i64 @file_write(i8* %9, i32 %12, i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %7
%19 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %7, %18, %4
%21 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %18 ], [ @EXIT_SUCCESS, %7 ]
%22 = load i32, i32* %21
ret i32 %22
}