#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);
scalar_t__ fclose(int /*<<< orphan*/);
scalar_t__ ferror(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fwrite(char *, int, size_t const, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
size_t strlen(char *);
unsigned long long strtoull(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "Usage: %s COUNT STRING\n", argv[0]);
    exit(1);
  }
  unsigned long long count = strtoull(argv[1], NULL, 10);
  const size_t size = strlen(argv[2]);
  while (count-- != 0)
    fwrite(argv[2], 1, size, stdout);
  return !!(ferror(stdout) || fclose(stdout));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11b6 <main+0x46>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoull@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     121e <main+0xae>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x20(%rbp),%rdx
mov    0x2dcb(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1090 <fwrite@plt>
jmp    11e1 <main+0x71>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    1256 <main+0xe6>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
call   1040 <fclose@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
cmp    $0x3,%edi
jne    1214 <main+0xa4>
mov    0x8(%r14),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoull@plt>
mov    %rax,%rbx
mov    0x10(%r14),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
test   %rbx,%rbx
je     11dd <main+0x6d>
mov    %rax,%r15
mov    0x2e25(%rip),%r13
mov    0x0(%r13),%ecx
mov    %r12,%rdi
nopw   0x0(%rax,%rax,1)
mov    $0x1,%esi
mov    %r15,%rdx
call   1090 <fwrite@plt>
add    $0xffffffffffffffff,%rbx
je     11dd <main+0x6d>
mov    0x10(%r14),%rdi
mov    0x0(%r13),%ecx
jmp    11c0 <main+0x50>
mov    0x2df4(%rip),%rbx
mov    (%rbx),%edi
call   1030 <ferror@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    120a <main+0x9a>
mov    (%rbx),%edi
call   1040 <fclose@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xdd9(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s COUNT STRING\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %17
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 ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strtoull(i8* %20, i32* null, i32 10)
store i64 %21, i64* %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i64 @strlen(i8* %24)
store i64 %25, i64* %7
br label %26
26: ; preds = %30, %17
%27 = load i64, i64* %6
%28 = add i64 %27, -1
store i64 %28, i64* %6
%29 = icmp ne i64 %27, 0
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = load i64, i64* %7
%35 = load i32, i32* @stdout
%36 = call i32 @fwrite(i8* %33, i32 1, i64 %34, i32 %35)
br label %26
37: ; preds = %26
%38 = load i32, i32* @stdout
%39 = call i64 @ferror(i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = load i32, i32* @stdout
%43 = call i64 @fclose(i32 %42)
%44 = icmp ne i64 %43, 0
br label %45
45: ; preds = %41, %37
%46 = phi i1 [ true, %37 ], [ %44, %41 ]
%47 = xor i1 %46, true
%48 = xor i1 %47, true
%49 = zext i1 %48 to i32
ret i32 %49
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s COUNT STRING\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strtoull(i8* nocapture %11, i32* null, i32 10)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i64 @strlen(i8* dereferenceable(1) %14)
%16 = icmp eq i64 %12, 0
br i1 %16, label %29, label %17
17: ; preds = %9
%18 = add i64 %12, -1
%19 = load i32, i32* @stdout
%20 = tail call i32 @fwrite(i8* %14, i32 1, i64 %15, i32 %19)
%21 = icmp eq i64 %18, 0
br i1 %21, label %29, label %22
22: ; preds = %17, %22
%23 = phi i64 [ %25, %22 ], [ %18, %17 ]
%24 = load i8*, i8** %13
%25 = add i64 %23, -1
%26 = load i32, i32* @stdout
%27 = tail call i32 @fwrite(i8* %24, i32 1, i64 %15, i32 %26)
%28 = icmp eq i64 %25, 0
br i1 %28, label %29, label %22
29: ; preds = %22, %17, %9
%30 = load i32, i32* @stdout
%31 = tail call i64 @ferror(i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i32, i32* @stdout
%35 = tail call i64 @fclose(i32 %34)
%36 = icmp ne i64 %35, 0
%37 = zext i1 %36 to i32
br label %38
38: ; preds = %33, %29
%39 = phi i32 [ 1, %29 ], [ %37, %33 ]
ret i32 %39
}