#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*/ errx(int, char *);
int /*<<< orphan*/ printf(char *, ...);
unsigned long strtol(char *, int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  unsigned long num;
  if (argc < 3)
    errx(2, "usage: num string");
  num = strtol(argv[1], 0, 10);
  if (!num)
    errx(2, "num must be numeric");
  for (;;) {
    if (!num)
      break;
    printf("%s", argv[2]);
    --num;
  }
  printf("\n");
  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)
cmpl   $0x3,-0x8(%rbp)
jge    1161 <main+0x31>
mov    $0x2,%edi
lea    0xea4(%rip),%rsi
call   1030 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1195 <main+0x65>
mov    $0x2,%edi
lea    0xe82(%rip),%rsi
call   1030 <errx@plt>
jmp    119a <main+0x6a>
cmpq   $0x0,-0x18(%rbp)
jne    11aa <main+0x7a>
jmp    11d1 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    119a <main+0x6a>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x2,%edi
jg     115e <main+0x1e>
lea    0xeac(%rip),%rsi
mov    $0x2,%edi
call   1040 <errx@plt>
mov    0x8(%r14),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
test   %rax,%rax
je     1196 <main+0x56>
mov    %rax,%rbx
lea    0xea9(%rip),%r15
nopl   (%rax)
mov    0x10(%r14),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%rbx
jne    1180 <main+0x40>
jmp    11a7 <main+0x67>
lea    0xe75(%rip),%rsi
mov    $0x2,%edi
call   1040 <errx@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"usage: num string\00"
@.str.1 = [20 x i8] c"num must be numeric\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @errx(i32 2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strtol(i8* %8, i32 0, i32 10)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @errx(i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %21
13: ; preds = %6
%14 = getelementptr inbounds i8*, i8** %1, i64 2
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ %9, %13 ], [ %19, %15 ]
%17 = load i8*, i8** %14
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = add i64 %16, -1
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %15
21: ; preds = %15, %11
%22 = tail call i32 @putchar(i32 10)
ret i32 0
}