#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 */
unsigned int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  unsigned int i;
  unsigned int number;
  char default_string[] = "A";
  char *string;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <number> [<string>]\n", argv[0]);
    fprintf(stderr, "\t<number>\t repeated times for the string.\n");
    fprintf(stderr, "\t<string>\t default: \"A\".\n");
    return -1;
  }
  number = atoi(argv[1]);
  if (argc == 2)
    string = default_string;
  else
    string = argv[2];
  for (i = 0; i < number; i++)
    printf("%s", string);
  return 0;
}


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)
mov    0xeb3(%rip),%ax
mov    %ax,-0x1a(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b3 <main+0x83>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    121e <main+0xee>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11da <main+0xaa>
lea    -0x1a(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11e6 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    1217 <main+0xe7>
mov    -0x28(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ed <main+0xbd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movw   $0x41,0x6(%rsp)
cmp    $0x1,%edi
jg     1188 <main+0x58>
mov    0x2e93(%rip),%rbx
mov    (%rbx),%edi
mov    (%r14),%rdx
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xeb6(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xed1(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%r14d
jmp    11d0 <main+0xa0>
mov    %edi,%ebp
mov    0x8(%r14),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
cmp    $0x2,%ebp
jne    11a1 <main+0x71>
lea    0x6(%rsp),%rbp
jmp    11a5 <main+0x75>
mov    0x10(%r14),%rbp
xor    %r14d,%r14d
test   %ebx,%ebx
je     11d0 <main+0xa0>
lea    0xeb1(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <printf@plt>
add    $0xffffffff,%ebx
jne    11c0 <main+0x90>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.default_string = [2 x i8] c"A\00"
@stderr = global i32 0
@.str = [31 x i8] c"Usage: %s <number> [<string>]\0A\00"
@.str.1 = [43 x i8] c"\09<number>\09 repeated times for the string.\0A\00"
@.str.2 = [26 x i8] c"\09<string>\09 default: \22A\22.\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [2 x i8]
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [2 x i8]* %8 to i8*
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %48
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %7
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8* %31, i8** %9
br label %36
32: ; preds = %23
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
store i8* %35, i8** %9
br label %36
36: ; preds = %32, %30
store i32 0, i32* %6
br label %37
37: ; preds = %44, %36
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = icmp ult i32 %38, %39
br i1 %40, label %41, label %47
41: ; preds = %37
%42 = load i8*, i8** %9
%43 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41
%45 = load i32, i32* %6
%46 = add i32 %45, 1
store i32 %46, i32* %6
br label %37
47: ; preds = %37
store i32 0, i32* %3
br label %48
48: ; preds = %47, %13
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Usage: %s <number> [<string>]\0A\00"
@.str.1 = [43 x i8] c"\09<number>\09 repeated times for the string.\0A\00"
@.str.2 = [26 x i8] c"\09<string>\09 default: \22A\22.\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = bitcast i16* %3 to i8*
store i16 65, i16* %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %30
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = icmp eq i32 %0, 2
br i1 %18, label %22, label %19
19: ; preds = %14
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
br label %22
22: ; preds = %14, %19
%23 = phi i8* [ %21, %19 ], [ %4, %14 ]
%24 = icmp eq i32 %17, 0
br i1 %24, label %30, label %25
25: ; preds = %22, %25
%26 = phi i32 [ %28, %25 ], [ 0, %22 ]
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%28 = add nuw i32 %26, 1
%29 = icmp eq i32 %28, %17
br i1 %29, label %30, label %25
30: ; preds = %25, %22, %6
%31 = phi i32 [ -1, %6 ], [ 0, %22 ], [ 0, %25 ]
ret i32 %31
}