#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_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  int fd;
  int i;
  int nWrites;
  fd = atoi(argv[1]);
  nWrites = atoi(argv[3]);
  for (i = 0; i < nWrites; i++) {
    write(fd, argv[2], 4);
  }
  write(fd, "\n", 1);
  close(fd);
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    119c <main+0x6c>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116d <main+0x3d>
mov    -0x14(%rbp),%edi
lea    0xe5a(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
jle    1176 <main+0x46>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rbx),%rsi
mov    %r14d,%edi
mov    $0x4,%edx
call   1030 <write@plt>
add    $0xffffffff,%ebp
jne    1160 <main+0x30>
lea    0xe83(%rip),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %r14d,%edi
call   1040 <close@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %6
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 3
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %8
store i32 0, i32* %7
br label %17
17: ; preds = %27, %2
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i32, i32* %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @write(i32 %22, i8* %25, i32 4)
br label %27
27: ; preds = %21
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %17
30: ; preds = %17
%31 = load i32, i32* %6
%32 = call i32 @write(i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%33 = load i32, i32* %6
%34 = call i32 @close(i32 %33)
%35 = load i32, i32* @EXIT_SUCCESS
ret i32 %35
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = getelementptr inbounds i8*, i8** %1, i64 3
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ 0, %10 ], [ %16, %12 ]
%14 = load i8*, i8** %11
%15 = tail call i32 @write(i32 %5, i8* %14, i32 4)
%16 = add nuw nsw i32 %13, 1
%17 = icmp eq i32 %16, %8
br i1 %17, label %18, label %12
18: ; preds = %12, %2
%19 = tail call i32 @write(i32 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%20 = tail call i32 @close(i32 %5)
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}