#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*/ B115200;
int O_NOCTTY;
int O_RDWR;
int O_SYNC;
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char getCharToSend();
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ set_interface_attribs(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ tcdrain(int);
int write(int, char *, int);
int main(int argc, char **argv) {
  unsigned int test_index = 1U;
  const unsigned int test_loops = 10000U;
  unsigned int errors_count = 0U;
  char *portname = NULL;
  int fd = 0;
  if (argc != 2) {
    fprintf(stderr, "Expected port name '/dev/ttyXXX'\n");
    return -1;
  }
  portname = argv[1];
  fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC);
  if (fd < 0) {
    fprintf(stderr, "Error opening %s: %s\n", portname, strerror(errno));
    return -1;
  }
  set_interface_attribs(fd, B115200);
  char charToSend = 0;
  char charRecv = 0;
  int wlen = 0;
  int rlen = 0;
  unsigned int row = 0;
  printf("Test Started:\n%04d: ", row++);
  do {
    charToSend = getCharToSend();
    wlen = write(fd, &charToSend, 1);
    if (wlen != 1) {
      fprintf(stderr, "Error from write: %d, %d\n", wlen, errno);
    }
    tcdrain(fd);
    rlen = read(fd, &charRecv, 1);
    if (rlen != 1) {
      fprintf(stderr, "Error from read: %d, %d\n", rlen, errno);
    }
    if (charRecv != charToSend) {
      errors_count++;
      printf("X");
    } else {
      printf("0x%02x ", (unsigned char)charToSend);
    }
    if ((test_index % 10) == 0) {
      printf("\n%04d: ", row++);
    }
  } while ((test_index++) <= test_loops);
  printf("\n");
  if (errors_count != 0U) {
    printf("Test FAILED\nThere was %d errors in Serial communication\n Check "
           "your setup\n",
           errors_count);
  } else {
    printf("Test PASSED\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x2710,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11f7 <main+0x67>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141f <main+0x28f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2dda(%rip),%rax
mov    (%rax),%esi
mov    0x2db9(%rip),%rax
or     (%rax),%esi
mov    0x2dc0(%rip),%rax
or     (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    127a <main+0xea>
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xdbb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141f <main+0x28f>
mov    -0x2c(%rbp),%edi
mov    0x2d34(%rip),%rax
mov    (%rax),%esi
call   1050 <set_interface_attribs@plt>
movb   $0x0,-0x2d(%rbp)
movb   $0x0,-0x2e(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10a0 <getCharToSend@plt>
mov    %al,-0x2d(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x2d(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x1,-0x34(%rbp)
je     130c <main+0x17c>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
mov    0x2cc4(%rip),%rax
mov    (%rax),%ecx
lea    0xd48(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x2c(%rbp),%edi
call   1030 <tcdrain@plt>
mov    -0x2c(%rbp),%edi
lea    -0x2e(%rbp),%rsi
mov    $0x1,%edx
call   1070 <read@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x1,-0x38(%rbp)
je     1355 <main+0x1c5>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%edx
mov    0x2c7b(%rip),%rax
mov    (%rax),%ecx
lea    0xd19(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movsbl -0x2e(%rbp),%eax
movsbl -0x2d(%rbp),%ecx
cmp    %ecx,%eax
je     1381 <main+0x1f1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    0xd0b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1393 <main+0x203>
movzbl -0x2d(%rbp),%esi
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
jne    13c1 <main+0x231>
mov    -0x3c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
lea    0xc8b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13c6 <main+0x236>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x2710,%eax
jbe    12c1 <main+0x131>
lea    0xc3d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     140a <main+0x27a>
mov    -0x1c(%rbp),%esi
lea    0xc8c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1418 <main+0x288>
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1356 <main+0x1a6>
mov    0x2e1d(%rip),%rcx
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x8(%rsi),%rbp
mov    0x2dff(%rip),%rcx
or     (%rcx),%eax
mov    %rbp,%rdi
mov    %eax,%esi
call   10b0 <open@plt>
test   %eax,%eax
js     1396 <main+0x1e6>
mov    %eax,%ebx
mov    0x2dba(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1070 <set_interface_attribs@plt>
movb   $0x0,0x2(%rsp)
lea    0xe25(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%r14d
xor    %r15d,%r15d
movl   $0x0,0x4(%rsp)
mov    $0x1,%r12d
jmp    1255 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14d
add    $0xffffffff,%r15d
cmp    $0xffffd8ef,%r15d
je     1374 <main+0x1c4>
mov    %r14d,%ebp
mov    $0xcccccccd,%eax
imul   %rax,%rbp
shr    $0x23,%rbp
xor    %eax,%eax
call   10c0 <getCharToSend@plt>
mov    %eax,%r13d
mov    %al,0x3(%rsp)
mov    %ebx,%edi
lea    0x3(%rsp),%rsi
mov    $0x1,%edx
call   1060 <write@plt>
cmp    $0x1,%eax
je     12ab <main+0xfb>
mov    0x2d38(%rip),%rcx
mov    (%rcx),%edi
mov    0x2d27(%rip),%rcx
mov    (%rcx),%ecx
lea    0xdab(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
add    %ebp,%ebp
mov    %ebx,%edi
call   1050 <tcdrain@plt>
mov    %ebx,%edi
lea    0x2(%rsp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x1,%eax
je     12ec <main+0x13c>
mov    0x2cf7(%rip),%rcx
mov    (%rcx),%edi
mov    0x2ce6(%rip),%rcx
mov    (%rcx),%ecx
lea    0xd84(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0x0(%rbp,%rbp,4),%eax
mov    $0x1,%ebp
sub    %eax,%ebp
cmp    %r13b,0x2(%rsp)
jne    1320 <main+0x170>
movzbl %r13b,%esi
lea    0xd77(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    %r15d,%ebp
jne    1240 <main+0x90>
jmp    1338 <main+0x188>
nopl   0x0(%rax,%rax,1)
addl   $0x1,0x4(%rsp)
mov    $0x58,%edi
call   1030 <putchar@plt>
cmp    %r15d,%ebp
jne    1240 <main+0x90>
lea    0x1(%r12),%ebp
lea    0xd01(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebp,%r12d
jmp    1240 <main+0x90>
mov    0x2c6b(%rip),%rax
mov    (%rax),%edi
lea    0xc9a(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    13d8 <main+0x228>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     13ca <main+0x21a>
lea    0xcfb(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    13d6 <main+0x226>
mov    0x2c2b(%rip),%rax
mov    (%rax),%ebx
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xc6e(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    13d8 <main+0x228>
lea    0xd02(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Expected port name '/dev/ttyXXX'\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_SYNC = global i32 0
@.str.1 = [22 x i8] c"Error opening %s: %s\0A\00"
@errno = global i32 0
@B115200 = global i32 0
@.str.2 = [21 x i8] c"Test Started:\0A%04d: \00"
@.str.3 = [26 x i8] c"Error from write: %d, %d\0A\00"
@.str.4 = [25 x i8] c"Error from read: %d, %d\0A\00"
@.str.5 = [2 x i8] c"X\00"
@.str.6 = [8 x i8] c"0x%02x \00"
@.str.7 = [8 x i8] c"\0A%04d: \00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [75 x i8] c"Test FAILED\0AThere was %d errors in Serial communication\0A Check your setup\0A\00"
@.str.10 = [13 x i8] c"Test PASSED\0A\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 i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8
%12 = alloca i8
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 10000, i32* %7
store i32 0, i32* %8
store i8* null, i8** %9
store i32 0, i32* %10
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %107
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %9
%25 = load i8*, i8** %9
%26 = load i32, i32* @O_RDWR
%27 = load i32, i32* @O_NOCTTY
%28 = or i32 %26, %27
%29 = load i32, i32* @O_SYNC
%30 = or i32 %28, %29
%31 = call i32 @open(i8* %25, i32 %30)
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %21
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %9
%37 = load i32, i32* @errno
%38 = call i8* @strerror(i32 %37)
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %36, i8* %38)
store i32 -1, i32* %3
br label %107
40: ; preds = %21
%41 = load i32, i32* %10
%42 = load i32, i32* @B115200
%43 = call i32 @set_interface_attribs(i32 %41, i32 %42)
store i8 0, i8* %11
store i8 0, i8* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
%44 = load i32, i32* %15
%45 = add i32 %44, 1
store i32 %45, i32* %15
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %47
47: ; preds = %93, %40
%48 = call signext i8 (...) @getCharToSend()
store i8 %48, i8* %11
%49 = load i32, i32* %10
%50 = call i32 @write(i32 %49, i8* %11, i32 1)
store i32 %50, i32* %13
%51 = load i32, i32* %13
%52 = icmp ne i32 %51, 1
br i1 %52, label %53, label %58
53: ; preds = %47
%54 = load i32, i32* @stderr
%55 = load i32, i32* %13
%56 = load i32, i32* @errno
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %55, i32 %56)
br label %58
58: ; preds = %53, %47
%59 = load i32, i32* %10
%60 = call i32 @tcdrain(i32 %59)
%61 = load i32, i32* %10
%62 = call i32 @read(i32 %61, i8* %12, i32 1)
store i32 %62, i32* %14
%63 = load i32, i32* %14
%64 = icmp ne i32 %63, 1
br i1 %64, label %65, label %70
65: ; preds = %58
%66 = load i32, i32* @stderr
%67 = load i32, i32* %14
%68 = load i32, i32* @errno
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %67, i32 %68)
br label %70
70: ; preds = %65, %58
%71 = load i8, i8* %12
%72 = sext i8 %71 to i32
%73 = load i8, i8* %11
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %72, %74
br i1 %75, label %76, label %80
76: ; preds = %70
%77 = load i32, i32* %8
%78 = add i32 %77, 1
store i32 %78, i32* %8
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %84
80: ; preds = %70
%81 = load i8, i8* %11
%82 = zext i8 %81 to i32
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %80, %76
%85 = load i32, i32* %6
%86 = urem i32 %85, 10
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = load i32, i32* %15
%90 = add i32 %89, 1
store i32 %90, i32* %15
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %89)
br label %92
92: ; preds = %88, %84
br label %93
93: ; preds = %92
%94 = load i32, i32* %6
%95 = add i32 %94, 1
store i32 %95, i32* %6
%96 = icmp ule i32 %94, 10000
br i1 %96, label %47, label %97
97: ; preds = %93
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%99 = load i32, i32* %8
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %97
%102 = load i32, i32* %8
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.9, i64 0, i64 0), i32 %102)
br label %106
104: ; preds = %97
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
br label %106
106: ; preds = %104, %101
store i32 0, i32* %3
br label %107
107: ; preds = %106, %34, %18
%108 = load i32, i32* %3
ret i32 %108
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Expected port name '/dev/ttyXXX'\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_SYNC = global i32 0
@.str.1 = [22 x i8] c"Error opening %s: %s\0A\00"
@errno = global i32 0
@B115200 = global i32 0
@.str.2 = [21 x i8] c"Test Started:\0A%04d: \00"
@.str.3 = [26 x i8] c"Error from write: %d, %d\0A\00"
@.str.4 = [25 x i8] c"Error from read: %d, %d\0A\00"
@.str.6 = [8 x i8] c"0x%02x \00"
@.str.7 = [8 x i8] c"\0A%04d: \00"
@.str.9 = [75 x i8] c"Test FAILED\0AThere was %d errors in Serial communication\0A Check your setup\0A\00"
@str = [12 x i8] c"Test PASSED\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i8
%5 = icmp eq i32 %0, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %75
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDWR
%13 = load i32, i32* @O_NOCTTY
%14 = or i32 %13, %12
%15 = load i32, i32* @O_SYNC
%16 = or i32 %14, %15
%17 = tail call i32 @open(i8* %11, i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %9
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = tail call i8* @strerror(i32 %21)
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %22)
br label %75
24: ; preds = %9
%25 = load i32, i32* @B115200
%26 = tail call i32 @set_interface_attribs(i32 %17, i32 %25)
store i8 0, i8* %4
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %28
28: ; preds = %63, %24
%29 = phi i32 [ 1, %24 ], [ %65, %63 ]
%30 = phi i32 [ 0, %24 ], [ %57, %63 ]
%31 = phi i32 [ 1, %24 ], [ %64, %63 ]
%32 = tail call signext i8 (...) @getCharToSend()
store i8 %32, i8* %3
%33 = call i32 @write(i32 %17, i8* %3, i32 1)
%34 = icmp eq i32 %33, 1
br i1 %34, label %39, label %35
35: ; preds = %28
%36 = load i32, i32* @stderr
%37 = load i32, i32* @errno
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %33, i32 %37)
br label %39
39: ; preds = %35, %28
%40 = tail call i32 @tcdrain(i32 %17)
%41 = call i32 @read(i32 %17, i8* %4, i32 1)
%42 = icmp eq i32 %41, 1
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = load i32, i32* @stderr
%45 = load i32, i32* @errno
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %41, i32 %45)
br label %47
47: ; preds = %43, %39
%48 = load i8, i8* %4
%49 = icmp eq i8 %48, %32
br i1 %49, label %53, label %50
50: ; preds = %47
%51 = add i32 %30, 1
%52 = tail call i32 @putchar(i32 88)
br label %56
53: ; preds = %47
%54 = zext i8 %32 to i32
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %50
%57 = phi i32 [ %51, %50 ], [ %30, %53 ]
%58 = urem i32 %29, 10
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = add i32 %31, 1
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %31)
br label %63
63: ; preds = %56, %60
%64 = phi i32 [ %61, %60 ], [ %31, %56 ]
%65 = add nuw nsw i32 %29, 1
%66 = icmp eq i32 %65, 10002
br i1 %66, label %67, label %28
67: ; preds = %63
%68 = tail call i32 @putchar(i32 10)
%69 = icmp eq i32 %57, 0
br i1 %69, label %72, label %70
70: ; preds = %67
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.9, i64 0, i64 0), i32 %57)
br label %74
72: ; preds = %67
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %74
74: ; preds = %72, %70
br label %75
75: ; preds = %74, %19, %6
%76 = phi i32 [ -1, %6 ], [ -1, %19 ], [ 0, %74 ]
ret i32 %76
}