#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int readPGM(unsigned char **image, char *filename, int *imageWidth,
            int *imageHeight, int *grayMax) {
  int PGM_HEADER_LINES = 3;
  FILE *input;
  int headerLines = 1;
  int scannedLines = 0;
  int counter = 0;
  char *lineBuffer = (char *)malloc(1024 + 1);
  char *split;
  char *format = (char *)malloc(1024 + 1);
  char P5[] = "P5";
  char comments[1024 + 1];
  input = fopen(filename, "r");
  printf("\nRead image file: %s\n", filename);
  while (scannedLines < headerLines) {
    fgets(lineBuffer, 1024, input);
    if (lineBuffer[0] != '#') {
      scannedLines = scannedLines + 1;
      if (scannedLines == 1) {
        split = strtok(lineBuffer, " \n");
        strcpy(format, split);
        if (strcmp(format, P5) == 0) {
          printf("FORMAT: %s\n", format);
          headerLines = PGM_HEADER_LINES;
        } else {
          printf("Only PGM P5 format is support.\n");
        }
      }
      if (scannedLines == 2) {
        split = strtok(lineBuffer, " \n");
        *imageWidth = atoi(split);
        printf("WIDTH: %d, ", *imageWidth);
        split = strtok(NULL, " \n");
        *imageHeight = atoi(split);
        printf("HEIGHT: %d\n", *imageHeight);
      }
      if (scannedLines == 3) {
        split = strtok(lineBuffer, " \n");
        *grayMax = atoi(split);
        printf("GRAYMAX: %d\n", *grayMax);
      }
    } else {
      strcpy(comments, lineBuffer);
      printf("comments: %s", comments);
    }
  }
  *image = (unsigned char *)malloc((*imageWidth) * (*imageHeight) *
                                   sizeof(unsigned char));
  counter = fread(*image, sizeof(unsigned char), (*imageWidth) * (*imageHeight),
                  input);
  printf("pixels read: %d\n", counter);
  printf("\n");
  fclose(input);
  free(lineBuffer);
  free(format);
  return 0;
}


x86 assembly (clang, -O0):
<readPGM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x3,-0x2c(%rbp)
movl   $0x1,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    $0x401,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    $0x401,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    0xdf2(%rip),%ax
mov    %ax,-0x63(%rbp)
mov    0xdea(%rip),%al
mov    %al,-0x61(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xddd(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    13d8 <readPGM+0x228>
mov    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     13ae <readPGM+0x1fe>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
cmpl   $0x1,-0x40(%rbp)
jne    12ea <readPGM+0x13a>
mov    -0x50(%rbp),%rdi
lea    0xd8e(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x58(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x60(%rbp),%rdi
lea    -0x63(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12d7 <readPGM+0x127>
mov    -0x60(%rbp),%rsi
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    12e5 <readPGM+0x135>
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12ea <readPGM+0x13a>
cmpl   $0x2,-0x40(%rbp)
jne    1366 <readPGM+0x1b6>
mov    -0x50(%rbp),%rdi
lea    0xd1c(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xce3(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x3,-0x40(%rbp)
jne    13a9 <readPGM+0x1f9>
mov    -0x50(%rbp),%rdi
lea    0xca0(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    13d3 <readPGM+0x223>
lea    -0x470(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x470(%rbp),%rsi
lea    0xca3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1241 <readPGM+0x91>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x20(%rbp),%rcx
imul   (%rcx),%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rax
imul   (%rax),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%esi
lea    0xc51(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xbe3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readPGM>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %r8,0x28(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,%rbp
mov    %rdi,0x20(%rsp)
mov    $0x401,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    $0x401,%edi
call   10c0 <malloc@plt>
mov    %rax,0x18(%rsp)
movb   $0x0,0x6(%rsp)
movw   $0x3550,0x4(%rsp)
lea    0xddc(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <fopen@plt>
mov    %rax,%r15
lea    0xdcc(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%r13d
lea    0x30(%rsp),%r14
xor    %r12d,%r12d
jmp    1285 <readPGM+0xb5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
lea    0xddd(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
cmp    %r13d,%r12d
jge    13c4 <readPGM+0x1f4>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
cmpb   $0x23,(%rbx)
je     1260 <readPGM+0x90>
test   %r12d,%r12d
je     1318 <readPGM+0x148>
cmp    $0x2,%r12d
je     1360 <readPGM+0x190>
cmp    $0x1,%r12d
jne    1399 <readPGM+0x1c9>
mov    %rbx,%rdi
lea    0xd5e(%rip),%rbp
mov    %rbp,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   10f0 <atoi@plt>
mov    0x10(%rsp),%rcx
mov    %eax,(%rcx)
lea    0xd4f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   10f0 <atoi@plt>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
lea    0xd32(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x2,%r12d
jmp    127c <readPGM+0xac>
mov    %rbx,%rdi
lea    0xcf9(%rip),%rsi
call   10e0 <strtok@plt>
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
call   1050 <strcpy@plt>
mov    %rbp,%rdi
lea    0x4(%rsp),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     13a2 <readPGM+0x1d2>
lea    0xd1d(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%r12d
jmp    127c <readPGM+0xac>
mov    %rbx,%rdi
lea    0xcb1(%rip),%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   10f0 <atoi@plt>
mov    0x28(%rsp),%rcx
mov    %eax,(%rcx)
lea    0xcbd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x3,%r12d
jmp    127c <readPGM+0xac>
add    $0x1,%r12d
jmp    127c <readPGM+0xac>
lea    0xc75(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x3,%r13d
mov    $0x1,%r12d
jmp    127c <readPGM+0xac>
mov    0x8(%rsp),%r12
mov    (%r12),%edi
mov    0x10(%rsp),%rbp
imul   0x0(%rbp),%edi
call   10c0 <malloc@plt>
mov    0x20(%rsp),%rcx
mov    %rax,(%rcx)
mov    (%r12),%edx
imul   0x0(%rbp),%edx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r15,%rcx
call   1070 <fread@plt>
lea    0xc5a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
call   1080 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.readPGM.P5 = [3 x i8] c"P5\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [22 x i8] c"\0ARead image file: %s\0A\00"
@.str.2 = [3 x i8] c" \0A\00"
@.str.3 = [12 x i8] c"FORMAT: %s\0A\00"
@.str.4 = [32 x i8] c"Only PGM P5 format is support.\0A\00"
@.str.5 = [12 x i8] c"WIDTH: %d, \00"
@.str.6 = [12 x i8] c"HEIGHT: %d\0A\00"
@.str.7 = [13 x i8] c"GRAYMAX: %d\0A\00"
@.str.8 = [13 x i8] c"comments: %s\00"
@.str.9 = [17 x i8] c"pixels read: %d\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @readPGM(i8** %0, i8* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca [3 x i8]
%20 = alloca [1025 x i8]
store i8** %0, i8*** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
store i32 3, i32* %11
store i32 1, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
%21 = call i64 @malloc(i32 1025)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %16
%23 = call i64 @malloc(i32 1025)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %18
%25 = bitcast [3 x i8]* %19 to i8*
%26 = load i8*, i8** %7
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %27, i32** %12
%28 = load i8*, i8** %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %103, %5
%31 = load i32, i32* %14
%32 = load i32, i32* %13
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %104
34: ; preds = %30
%35 = load i8*, i8** %16
%36 = load i32*, i32** %12
%37 = call i32 @fgets(i8* %35, i32 1024, i32* %36)
%38 = load i8*, i8** %16
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 35
br i1 %42, label %43, label %97
43: ; preds = %34
%44 = load i32, i32* %14
%45 = add nsw i32 %44, 1
store i32 %45, i32* %14
%46 = load i32, i32* %14
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %65
48: ; preds = %43
%49 = load i8*, i8** %16
%50 = call i8* @strtok(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %50, i8** %17
%51 = load i8*, i8** %18
%52 = load i8*, i8** %17
%53 = call i32 @strcpy(i8* %51, i8* %52)
%54 = load i8*, i8** %18
%55 = getelementptr inbounds [3 x i8], [3 x i8]* %19, i64 0, i64 0
%56 = call i64 @strcmp(i8* %54, i8* %55)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %48
%59 = load i8*, i8** %18
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %59)
%61 = load i32, i32* %11
store i32 %61, i32* %13
br label %64
62: ; preds = %48
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %64
64: ; preds = %62, %58
br label %65
65: ; preds = %64, %43
%66 = load i32, i32* %14
%67 = icmp eq i32 %66, 2
br i1 %67, label %68, label %84
68: ; preds = %65
%69 = load i8*, i8** %16
%70 = call i8* @strtok(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %70, i8** %17
%71 = load i8*, i8** %17
%72 = call i32 @atoi(i8* %71)
%73 = load i32*, i32** %8
store i32 %72, i32* %73
%74 = load i32*, i32** %8
%75 = load i32, i32* %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %75)
%77 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %77, i8** %17
%78 = load i8*, i8** %17
%79 = call i32 @atoi(i8* %78)
%80 = load i32*, i32** %9
store i32 %79, i32* %80
%81 = load i32*, i32** %9
%82 = load i32, i32* %81
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %68, %65
%85 = load i32, i32* %14
%86 = icmp eq i32 %85, 3
br i1 %86, label %87, label %96
87: ; preds = %84
%88 = load i8*, i8** %16
%89 = call i8* @strtok(i8* %88, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %89, i8** %17
%90 = load i8*, i8** %17
%91 = call i32 @atoi(i8* %90)
%92 = load i32*, i32** %10
store i32 %91, i32* %92
%93 = load i32*, i32** %10
%94 = load i32, i32* %93
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %94)
br label %96
96: ; preds = %87, %84
br label %103
97: ; preds = %34
%98 = getelementptr inbounds [1025 x i8], [1025 x i8]* %20, i64 0, i64 0
%99 = load i8*, i8** %16
%100 = call i32 @strcpy(i8* %98, i8* %99)
%101 = getelementptr inbounds [1025 x i8], [1025 x i8]* %20, i64 0, i64 0
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %101)
br label %103
103: ; preds = %97, %96
br label %30
104: ; preds = %30
%105 = load i32*, i32** %8
%106 = load i32, i32* %105
%107 = load i32*, i32** %9
%108 = load i32, i32* %107
%109 = mul nsw i32 %106, %108
%110 = sext i32 %109 to i64
%111 = mul i64 %110, 1
%112 = trunc i64 %111 to i32
%113 = call i64 @malloc(i32 %112)
%114 = inttoptr i64 %113 to i8*
%115 = load i8**, i8*** %6
store i8* %114, i8** %115
%116 = load i8**, i8*** %6
%117 = load i8*, i8** %116
%118 = load i32*, i32** %8
%119 = load i32, i32* %118
%120 = load i32*, i32** %9
%121 = load i32, i32* %120
%122 = mul nsw i32 %119, %121
%123 = load i32*, i32** %12
%124 = call i32 @fread(i8* %117, i32 1, i32 %122, i32* %123)
store i32 %124, i32* %15
%125 = load i32, i32* %15
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %125)
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%128 = load i32*, i32** %12
%129 = call i32 @fclose(i32* %128)
%130 = load i8*, i8** %16
%131 = call i32 @free(i8* %130)
%132 = load i8*, i8** %18
%133 = call i32 @free(i8* %132)
ret i32 0
}

LLVM IR (-O2):
@__const.readPGM.P5 = [3 x i8] c"P5\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [22 x i8] c"\0ARead image file: %s\0A\00"
@.str.2 = [3 x i8] c" \0A\00"
@.str.3 = [12 x i8] c"FORMAT: %s\0A\00"
@.str.5 = [12 x i8] c"WIDTH: %d, \00"
@.str.6 = [12 x i8] c"HEIGHT: %d\0A\00"
@.str.7 = [13 x i8] c"GRAYMAX: %d\0A\00"
@.str.8 = [13 x i8] c"comments: %s\00"
@.str.9 = [17 x i8] c"pixels read: %d\0A\00"
@str = [31 x i8] c"Only PGM P5 format is support.\00"
define i32 @readPGM(i8** nocapture writeonly %0, i8* %1, i32* nocapture %2, i32* nocapture %3, i32* nocapture writeonly %4) {
%6 = alloca [3 x i8]
%7 = alloca [1025 x i8]
%8 = tail call i64 @malloc(i32 1025)
%9 = inttoptr i64 %8 to i8*
%10 = tail call i64 @malloc(i32 1025)
%11 = inttoptr i64 %10 to i8*
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%14 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %16
16: ; preds = %5, %49
%17 = phi i32 [ 1, %5 ], [ %51, %49 ]
%18 = phi i32 [ 0, %5 ], [ %50, %49 ]
%19 = call i32 @fgets(i8* %9, i32 1024, i32* %14)
%20 = load i8, i8* %9
%21 = icmp eq i8 %20, 35
br i1 %21, label %46, label %22
22: ; preds = %16
%23 = icmp eq i32 %18, 0
br i1 %23, label %24, label %33
24: ; preds = %22
%25 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @strcpy(i8* %11, i8* %25)
%27 = call i64 @strcmp(i8* %11, i8* %12)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %49
31: ; preds = %24
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %49
33: ; preds = %22
%34 = add nsw i32 %18, 1
switch i32 %18, label %49 [
i32 1, label %35
i32 2, label %42
]
35: ; preds = %33
%36 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %37)
%39 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @atoi(i8* %39)
store i32 %40, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %40)
br label %49
42: ; preds = %33
%43 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @atoi(i8* %43)
store i32 %44, i32* %4
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %44)
br label %49
46: ; preds = %16
%47 = call i32 @strcpy(i8* %13, i8* %9)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %13)
br label %49
49: ; preds = %31, %29, %35, %33, %42, %46
%50 = phi i32 [ 3, %42 ], [ 2, %35 ], [ %18, %46 ], [ %34, %33 ], [ 1, %29 ], [ 1, %31 ]
%51 = phi i32 [ %17, %42 ], [ %17, %35 ], [ %17, %46 ], [ %17, %33 ], [ 3, %29 ], [ %17, %31 ]
%52 = icmp slt i32 %50, %51
br i1 %52, label %16, label %53
53: ; preds = %49
%54 = load i32, i32* %2
%55 = load i32, i32* %3
%56 = mul nsw i32 %55, %54
%57 = call i64 @malloc(i32 %56)
%58 = inttoptr i64 %57 to i8*
store i8* %58, i8** %0
%59 = load i32, i32* %2
%60 = load i32, i32* %3
%61 = mul nsw i32 %60, %59
%62 = call i32 @fread(i8* %58, i32 1, i32 %61, i32* %14)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %62)
%64 = call i32 @putchar(i32 10)
%65 = call i32 @fclose(i32* %14)
%66 = call i32 @free(i8* %9)
%67 = call i32 @free(i8* %11)
ret i32 0
}