#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, scalar_t__);
int /*<<< orphan*/ strncpy(char *, char *, scalar_t__);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("Need at least 1 arg\n");
    return (1);
  }
  int last = atoi(argv[1]);
  char start[50] = {0};
  char end[50] = {0};
  if (argc == 4) {
    strncat(start, argv[2], strlen(argv[2]));
    strncpy(end, argv[3], strlen(argv[3]));
  }
  int i;
  for (i = 0; i < last; ++i) {
    if (strlen(start))
      printf("%s", start);
    printf("%03d", i + 1);
    if (strlen(end))
      printf("%s", end);
    printf("\n");
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119d <main+0x3d>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1300 <main+0x1a0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1060 <memset@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1060 <memset@plt>
cmpl   $0x4,-0x8(%rbp)
jne    1257 <main+0xf7>
lea    -0x50(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
mov    -0xb8(%rbp),%rdi
mov    -0xb0(%rbp),%rsi
mov    %rax,%rdx
call   1070 <strncat@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
mov    %rax,%rdx
call   1030 <strncpy@plt>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12f9 <main+0x199>
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
je     1295 <main+0x135>
lea    -0x50(%rbp),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x94(%rbp),%esi
add    $0x1,%esi
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
je     12d7 <main+0x177>
lea    -0x90(%rbp),%rsi
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1261 <main+0x101>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
cmp    $0x1,%edi
jg     1199 <main+0x29>
lea    0xe7e(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%eax
jmp    1294 <main+0x124>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%r15d
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movw   $0x0,0x70(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movw   $0x0,0x30(%rsp)
cmp    $0x4,%ebp
jne    1213 <main+0xa3>
mov    0x10(%rbx),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    0x40(%rsp),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1080 <strncat@plt>
mov    0x18(%rbx),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
test   %r15d,%r15d
jle    1292 <main+0x122>
neg    %r15d
mov    $0x1,%ebx
lea    0xddc(%rip),%r14
lea    0xdd2(%rip),%r12
mov    %rsp,%r13
lea    0x40(%rsp),%rbp
jmp    125d <main+0xed>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     1292 <main+0x122>
cmpb   $0x0,0x40(%rsp)
je     1271 <main+0x101>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
cmpb   $0x0,(%rsp)
je     1240 <main+0xd0>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1240 <main+0xd0>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Need at least 1 arg\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"%03d\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 i32
%7 = alloca [50 x i8]
%8 = alloca [50 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %70
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %6
%19 = bitcast [50 x i8]* %7 to i8*
%20 = bitcast [50 x i8]* %8 to i8*
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 4
br i1 %22, label %23, label %42
23: ; preds = %14
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i64 @strlen(i8* %30)
%32 = call i32 @strncat(i8* %24, i8* %27, i64 %31)
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i8*, i8** %38
%40 = call i64 @strlen(i8* %39)
%41 = call i32 @strncpy(i8* %33, i8* %36, i64 %40)
br label %42
42: ; preds = %23, %14
store i32 0, i32* %9
br label %43
43: ; preds = %66, %42
%44 = load i32, i32* %9
%45 = load i32, i32* %6
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %69
47: ; preds = %43
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%49 = call i64 @strlen(i8* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %51, %47
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%59 = call i64 @strlen(i8* %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %54
%62 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %61, %54
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %66
66: ; preds = %64
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %43
69: ; preds = %43
store i32 0, i32* %3
br label %70
70: ; preds = %69, %12
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"%03d\00"
@str = [20 x i8] c"Need at least 1 arg\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %43
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%14 = icmp eq i32 %0, 4
br i1 %14, label %15, label %24
15: ; preds = %8
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i64 @strlen(i8* dereferenceable(1) %17)
%19 = call i32 @strncat(i8* %12, i8* %17, i64 %18)
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = call i64 @strlen(i8* dereferenceable(1) %21)
%23 = call i32 @strncpy(i8* %13, i8* %21, i64 %22)
br label %24
24: ; preds = %15, %8
%25 = icmp sgt i32 %11, 0
br i1 %25, label %26, label %42
26: ; preds = %24, %39
%27 = phi i32 [ %33, %39 ], [ 0, %24 ]
%28 = load i8, i8* %12
%29 = icmp eq i8 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %32
32: ; preds = %30, %26
%33 = add nuw nsw i32 %27, 1
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i8, i8* %13
%36 = icmp eq i8 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %32
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %39
39: ; preds = %37, %32
%40 = call i32 @putchar(i32 10)
%41 = icmp eq i32 %33, %11
br i1 %41, label %42, label %26
42: ; preds = %39, %24
br label %43
43: ; preds = %42, %6
%44 = phi i32 [ 1, %6 ], [ 0, %42 ]
ret i32 %44
}