#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*/ PrintOutput(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
long ftell(int /*<<< orphan*/);
char *igtest(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void main(int argc, char **argv) {
  char input[256];
  long position;
  int argno;
  char *szOutput;
  if (argc == 1) {
    position = ftell(stdin);
    do {
      if (position == -1)
        fprintf(stderr, "\nigtest:> ");
      if (fgets((char *)input, 256, stdin) != NULL) {
        if (input[strlen((char *)input) - 1] == '\n')
          (input[strlen((char *)input) - 1] = '\0');
        if (strlen(input) == 0)
          break;
        szOutput = igtest(input);
        if (szOutput != NULL)
          PrintOutput(szOutput);
        else
          printf("wrong input format\n");
      } else
        break;
    } while (1);
  } else {
    strcpy(input, "");
    for (argno = 1; argno < argc; argno++) {
      strcat(input, argv[argno]);
      strcat(input, " ");
    }
    input[strlen((char *)input) - 1] = '\0';
    szOutput = igtest(input);
    if (szOutput != NULL)
      PrintOutput(szOutput);
    else
      printf("wrong input format\n");
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    12ce <main+0x12e>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1090 <ftell@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0xffffffffffffffff,-0x118(%rbp)
ff
jne    11f4 <main+0x54>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
call   1080 <fprintf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12b0 <main+0x110>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1253 <main+0xb3>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    126d <main+0xcd>
jmp    12c9 <main+0x129>
lea    -0x110(%rbp),%rdi
call   10c0 <igtest@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
je     129f <main+0xff>
mov    -0x128(%rbp),%rdi
call   1070 <PrintOutput@plt>
jmp    12ab <main+0x10b>
lea    0xd65(%rip),%rdi
call   1050 <printf@plt>
jmp    12b5 <main+0x115>
jmp    12c9 <main+0x129>
jmp    12ba <main+0x11a>
mov    $0x1,%al
test   $0x1,%al
jne    11d1 <main+0x31>
jmp    12c9 <main+0x129>
jmp    1398 <main+0x1f8>
lea    -0x110(%rbp),%rdi
lea    0xd42(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x11c(%rbp)
mov    -0x11c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    133c <main+0x19c>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x11c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10a0 <strcat@plt>
lea    -0x110(%rbp),%rdi
lea    0xce6(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
jmp    12eb <main+0x14b>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
call   10c0 <igtest@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
je     1387 <main+0x1e7>
mov    -0x128(%rbp),%rdi
call   1070 <PrintOutput@plt>
jmp    1393 <main+0x1f3>
lea    0xc7d(%rip),%rdi
call   1050 <printf@plt>
jmp    1398 <main+0x1f8>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
cmp    $0x1,%edi
jne    1270 <main+0xd0>
mov    0x2e27(%rip),%r13
mov    0x0(%r13),%edi
call   1090 <ftell@plt>
mov    %rax,%r15
mov    0x2e04(%rip),%rbp
lea    0xe25(%rip),%r14
mov    %rsp,%rbx
lea    0xe26(%rip),%r12
cmp    $0xffffffffffffffff,%r15
jne    1209 <main+0x69>
jmp    11fe <main+0x5e>
nopl   (%rax)
mov    %rax,%rdi
call   1070 <PrintOutput@plt>
cmp    $0xffffffffffffffff,%r15
jne    1209 <main+0x69>
mov    0x0(%rbp),%edi
mov    %r14,%rsi
call   1080 <fprintf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     12e9 <main+0x149>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1243 <main+0xa3>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
je     12e9 <main+0x149>
mov    %rbx,%rdi
call   10c0 <igtest@plt>
test   %rax,%rax
jne    11f0 <main+0x50>
mov    %r12,%rdi
call   1040 <puts@plt>
cmp    $0xffffffffffffffff,%r15
jne    1209 <main+0x69>
jmp    11fe <main+0x5e>
mov    %rsi,%r15
mov    %edi,%ebx
lea    0xd8e(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
cmp    $0x2,%ebx
jl     12c0 <main+0x120>
mov    %ebx,%r13d
mov    $0x1,%ebp
mov    %rsp,%rbx
lea    0xd6b(%rip),%r12
xchg   %ax,%ax
mov    (%r15,%rbp,8),%rsi
mov    %rbx,%rdi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <strcat@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    12a0 <main+0x100>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %r14,%rdi
call   10c0 <igtest@plt>
test   %rax,%rax
jne    12f0 <main+0x150>
lea    0xd27(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    %rax,%rdi
call   1070 <PrintOutput@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"\0Aigtest:> \00"
@.str.1 = [20 x i8] c"wrong input format\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c" \00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [256 x i8]
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %60
11: ; preds = %2
%12 = load i32, i32* @stdin
%13 = call i64 @ftell(i32 %12)
store i64 %13, i64* %6
br label %14
14: ; preds = %58, %11
%15 = load i64, i64* %6
%16 = icmp eq i64 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %17, %14
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%22 = load i32, i32* @stdin
%23 = call i32* @fgets(i8* %21, i32 256, i32 %22)
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %56
25: ; preds = %20
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %40
34: ; preds = %25
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %34, %25
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %40
br label %59
45: ; preds = %40
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%47 = call i8* @igtest(i8* %46)
store i8* %47, i8** %8
%48 = load i8*, i8** %8
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %53
50: ; preds = %45
%51 = load i8*, i8** %8
%52 = call i32 @PrintOutput(i8* %51)
br label %55
53: ; preds = %45
%54 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
br label %57
56: ; preds = %20
br label %59
57: ; preds = %55
br label %58
58: ; preds = %57
br i1 true, label %14, label %59
59: ; preds = %58, %56, %44
br label %96
60: ; preds = %2
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%62 = call i32 @strcpy(i8* %61, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %7
br label %63
63: ; preds = %77, %60
%64 = load i32, i32* %7
%65 = load i32, i32* %3
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %80
67: ; preds = %63
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%69 = load i8**, i8*** %4
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8*, i8** %69, i64 %71
%73 = load i8*, i8** %72
%74 = call i32 @strcat(i8* %68, i8* %73)
%75 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%76 = call i32 @strcat(i8* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %77
77: ; preds = %67
%78 = load i32, i32* %7
%79 = add nsw i32 %78, 1
store i32 %79, i32* %7
br label %63
80: ; preds = %63
%81 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%82 = call i32 @strlen(i8* %81)
%83 = sub nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %84
store i8 0, i8* %85
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%87 = call i8* @igtest(i8* %86)
store i8* %87, i8** %8
%88 = load i8*, i8** %8
%89 = icmp ne i8* %88, null
br i1 %89, label %90, label %93
90: ; preds = %80
%91 = load i8*, i8** %8
%92 = call i32 @PrintOutput(i8* %91)
br label %95
93: ; preds = %80
%94 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %95
95: ; preds = %93, %90
br label %96
96: ; preds = %95, %59
%97 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"\0Aigtest:> \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c" \00"
@str.4 = [19 x i8] c"wrong input format\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %41
6: ; preds = %2
%7 = load i32, i32* @stdin
%8 = tail call i64 @ftell(i32 %7)
%9 = icmp eq i64 %8, -1
br label %10
10: ; preds = %40, %6
br i1 %9, label %11, label %14
11: ; preds = %10
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %10
%15 = load i32, i32* @stdin
%16 = call i32* @fgets(i8* %4, i32 256, i32 %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %65, label %18
18: ; preds = %14
%19 = call i32 @strlen(i8* %4)
%20 = add nsw i32 %19, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 10
br i1 %24, label %25, label %30
25: ; preds = %18
%26 = call i32 @strlen(i8* %4)
%27 = add nsw i32 %26, -1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
br label %30
30: ; preds = %25, %18
%31 = call i32 @strlen(i8* %4)
%32 = icmp eq i32 %31, 0
br i1 %32, label %65, label %33
33: ; preds = %30
%34 = call i8* @igtest(i8* %4)
%35 = icmp eq i8* %34, null
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = call i32 @PrintOutput(i8* %34)
br label %40
38: ; preds = %33
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.4, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %10
41: ; preds = %2
%42 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp sgt i32 %0, 1
br i1 %43, label %44, label %54
44: ; preds = %41
%45 = zext i32 %0 to i64
br label %46
46: ; preds = %44, %46
%47 = phi i64 [ 1, %44 ], [ %52, %46 ]
%48 = getelementptr inbounds i8*, i8** %1, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 @strcat(i8* %4, i8* %49)
%51 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%52 = add nuw nsw i64 %47, 1
%53 = icmp eq i64 %52, %45
br i1 %53, label %54, label %46
54: ; preds = %46, %41
%55 = call i32 @strlen(i8* %4)
%56 = add nsw i32 %55, -1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %57
store i8 0, i8* %58
%59 = call i8* @igtest(i8* %4)
%60 = icmp eq i8* %59, null
br i1 %60, label %63, label %61
61: ; preds = %54
%62 = call i32 @PrintOutput(i8* %59)
br label %65
63: ; preds = %54
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.4, i64 0, i64 0))
br label %65
65: ; preds = %30, %14, %61, %63
%66 = call i32 @exit(i32 0)
unreachable
}