#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
char *malloc(int);
int /*<<< orphan*/ strcmp(char *, char *);
int main(void) {
  int np, i = 0, check = 0, many[10], j = 0, check2 = 0, c = 1, a;
  char *names[10], from[14], to[14];
  int amount[10], amou;
  FILE *fin, *fout;
  fin = fopen("gift1.in", "r");
  fout = fopen("gift1.out", "w");
  fscanf(fin, "%d", &np);
  for (i = 0; i < np; i++) {
    amount[i] = 0;
  }
  for (i = 0; i < np; i++) {
    names[i] = malloc(14 * sizeof(char));
    fscanf(fin, "%s", names[i]);
  }
  while (check2 < np) {
    fscanf(fin, "%s", from);
    i = 0;
    c = 1;
    while (i < np && c) {
      if (!strcmp(from, names[i])) {
        check = i;
        c = 0;
      }
      i++;
    }
    fscanf(fin, "%d", &amou);
    fscanf(fin, "%d", &many[check]);
    a = many[check];
    if (a != 0) {
      amount[check] -= a * (amou / a);
    }
    for (i = 0; i < many[check]; i++) {
      fscanf(fin, "%s", to);
      j = 0;
      c = 1;
      while (j < np && c) {
        if (!strcmp(to, names[j])) {
          amount[j] += amou / many[check];
          c = 0;
        }
        j++;
      }
    }
    check2 += 1;
  }
  for (i = 0; i < np; i++) {
    fprintf(fout, "%s %d\n", names[i], amount[i]);
  }
  fclose(fin);
  fclose(fout);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x1,-0x4c(%rbp)
lea    0xe64(%rip),%rdi
lea    0xe66(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x100(%rbp)
lea    0xe55(%rip),%rdi
lea    0xe58(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x108(%rbp)
mov    -0x100(%rbp),%rdi
lea    0xe40(%rip),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1212 <main+0xb2>
movslq -0xc(%rbp),%rax
movl   $0x0,-0xf0(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e9 <main+0x89>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126d <main+0x10d>
mov    $0xe,%edi
call   1070 <malloc@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
mov    %rcx,-0xa0(%rbp,%rax,8)
ff
mov    -0x100(%rbp),%rdi
movslq -0xc(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rdx
ff
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1219 <main+0xb9>
jmp    1272 <main+0x112>
mov    -0x48(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    148d <main+0x32d>
mov    -0x100(%rbp),%rdi
lea    -0xae(%rbp),%rdx
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x109(%rbp)
jge    12c9 <main+0x169>
cmpl   $0x0,-0x4c(%rbp)
setne  %al
mov    %al,-0x109(%rbp)
mov    -0x109(%rbp),%al
test   $0x1,%al
jne    12dc <main+0x17c>
jmp    1318 <main+0x1b8>
lea    -0xae(%rbp),%rdi
movslq -0xc(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rsi
ff
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    130a <main+0x1aa>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12a8 <main+0x148>
mov    -0x100(%rbp),%rdi
lea    0xcf1(%rip),%rsi
lea    -0xf4(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x100(%rbp),%rdi
movslq -0x10(%rbp),%rax
lea    -0x40(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xcc6(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
movslq -0x10(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
je     139d <main+0x23d>
mov    -0x50(%rbp),%eax
mov    %eax,-0x110(%rbp)
mov    -0xf4(%rbp),%eax
cltd
idivl  -0x50(%rbp)
mov    -0x110(%rbp),%edx
imul   %eax,%edx
movslq -0x10(%rbp),%rax
mov    -0xf0(%rbp,%rax,4),%ecx
sub    %edx,%ecx
mov    %ecx,-0xf0(%rbp,%rax,4)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movslq -0x10(%rbp),%rcx
cmp    -0x40(%rbp,%rcx,4),%eax
jge    147f <main+0x31f>
mov    -0x100(%rbp),%rdi
lea    -0xbc(%rbp),%rdx
lea    0xc50(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0x44(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x44(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x111(%rbp)
jge    1400 <main+0x2a0>
cmpl   $0x0,-0x4c(%rbp)
setne  %al
mov    %al,-0x111(%rbp)
mov    -0x111(%rbp),%al
test   $0x1,%al
jne    1413 <main+0x2b3>
jmp    146c <main+0x30c>
lea    -0xbc(%rbp),%rdi
movslq -0x44(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rsi
ff
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    145e <main+0x2fe>
mov    -0xf4(%rbp),%eax
movslq -0x10(%rbp),%rcx
cltd
idivl  -0x40(%rbp,%rcx,4)
mov    %eax,%ecx
movslq -0x44(%rbp),%rax
add    -0xf0(%rbp,%rax,4),%ecx
mov    %ecx,-0xf0(%rbp,%rax,4)
movl   $0x0,-0x4c(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    13df <main+0x27f>
jmp    1471 <main+0x311>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    13a4 <main+0x244>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1272 <main+0x112>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14d8 <main+0x378>
mov    -0x108(%rbp),%rdi
movslq -0xc(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rdx
ff
movslq -0xc(%rbp),%rax
mov    -0xf0(%rbp,%rax,4),%ecx
lea    0xb58(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1494 <main+0x334>
mov    -0x100(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x108(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
lea    0xe78(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0xe6d(%rip),%rdi
lea    0xe70(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0xe63(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%r13
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    (%rsp),%edx
test   %edx,%edx
jle    13c1 <main+0x251>
shl    $0x2,%rdx
lea    0x30(%rsp),%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe34(%rip),%r15
xor    %ebx,%ebx
mov    %r13,%rbp
nopl   0x0(%rax,%rax,1)
mov    $0xe,%edi
call   1080 <malloc@plt>
mov    %rax,0x70(%rsp,%rbx,8)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0x1,%rbx
movslq (%rsp),%rax
cmp    %rax,%rbx
jl     11f0 <main+0x80>
test   %eax,%eax
jle    13c1 <main+0x251>
mov    %r14,0x18(%rsp)
lea    0x62(%rsp),%r14
xor    %r15d,%r15d
xor    %ebx,%ebx
mov    %r13,%rbp
jmp    1254 <main+0xe4>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%r12d
mov    0x8(%rsp),%ebx
add    $0x1,%ebx
cmp    %r12d,%ebx
jge    1381 <main+0x211>
mov    %rbp,%rdi
lea    0xdbc(%rip),%rsi
lea    0x22(%rsp),%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    (%rsp),%r12d
test   %r12d,%r12d
mov    %ebx,0x8(%rsp)
mov    %rbp,%r13
jle    12a6 <main+0x136>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r15d,%ebx
mov    0x70(%rsp,%rbp,8),%rsi
lea    0x22(%rsp),%rdi
call   1060 <strcmp@plt>
mov    %ebp,%r15d
test   %eax,%eax
cmovne %ebx,%r15d
je     12a6 <main+0x136>
add    $0x1,%rbp
cmp    %r12,%rbp
jb     1280 <main+0x110>
mov    %r13,%rbp
mov    %r13,%rdi
lea    0xd64(%rip),%r12
mov    %r12,%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
movslq %r15d,%rbx
lea    (%rsp,%rbx,4),%rdx
add    $0xc0,%rdx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rdx,0x10(%rsp)
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0xc0(%rsp,%rbx,4),%esi
test   %esi,%esi
je     1240 <main+0xd0>
mov    0x4(%rsp),%ecx
mov    %ecx,%eax
cltd
idiv   %esi
sub    %ecx,%edx
add    %edx,0x30(%rsp,%rbx,4)
test   %esi,%esi
jle    1240 <main+0xd0>
xor    %ebx,%ebx
jmp    1333 <main+0x1c3>
nopl   0x0(%rax)
mov    0xc(%rsp),%eax
cltd
mov    0x10(%rsp),%rcx
idivl  (%rcx)
add    %eax,0x2c(%rsp,%rbp,4)
add    $0x1,%ebx
mov    0x10(%rsp),%rax
cmp    (%rax),%ebx
mov    %r13,%rbp
jge    1244 <main+0xd4>
mov    %rbp,%r13
mov    %rbp,%rdi
lea    0xcda(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    (%rsp),%r12d
test   %r12d,%r12d
jle    1320 <main+0x1b0>
mov    $0x1,%ebp
mov    0x4(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    0x68(%rsp,%rbp,8),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1310 <main+0x1a0>
je     1320 <main+0x1b0>
lea    0x1(%rbp),%rax
cmp    %r12,%rbp
mov    %rax,%rbp
jb     1360 <main+0x1f0>
jmp    1320 <main+0x1b0>
mov    %rbp,%r13
test   %r12d,%r12d
mov    0x18(%rsp),%r14
jle    13c1 <main+0x251>
xor    %ebx,%ebx
lea    0xc86(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    0x70(%rsp,%rbx,8),%rdx
mov    0x30(%rsp,%rbx,4),%ecx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <fprintf@plt>
add    $0x1,%rbx
movslq (%rsp),%rax
cmp    %rax,%rbx
jl     13a0 <main+0x230>
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"gift1.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"gift1.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [7 x i8] c"%s %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [10 x i8*]
%11 = alloca [14 x i8]
%12 = alloca [14 x i8]
%13 = alloca [10 x i32]
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
%17 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %15
%18 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %18, i32** %16
%19 = load i32*, i32** %15
%20 = call i32 (i32*, i8*, ...) @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %21
21: ; preds = %29, %0
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %13, i64 0, i64 %27
store i32 0, i32* %28
br label %29
29: ; preds = %25
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %21
32: ; preds = %21
store i32 0, i32* %3
br label %33
33: ; preds = %48, %32
%34 = load i32, i32* %3
%35 = load i32, i32* %2
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %51
37: ; preds = %33
%38 = call i8* @malloc(i32 14)
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %40
store i8* %38, i8** %41
%42 = load i32*, i32** %15
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i32*, i8*, ...) @fscanf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %37
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %33
51: ; preds = %33
br label %52
52: ; preds = %155, %51
%53 = load i32, i32* %7
%54 = load i32, i32* %2
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %158
56: ; preds = %52
%57 = load i32*, i32** %15
%58 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 0
%59 = call i32 (i32*, i8*, ...) @fscanf(i32* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %58)
store i32 0, i32* %3
store i32 1, i32* %8
br label %60
60: ; preds = %79, %56
%61 = load i32, i32* %3
%62 = load i32, i32* %2
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = load i32, i32* %8
%66 = icmp ne i32 %65, 0
br label %67
67: ; preds = %64, %60
%68 = phi i1 [ false, %60 ], [ %66, %64 ]
br i1 %68, label %69, label %82
69: ; preds = %67
%70 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 0
%71 = load i32, i32* %3
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 @strcmp(i8* %70, i8* %74)
%76 = icmp ne i32 %75, 0
br i1 %76, label %79, label %77
77: ; preds = %69
%78 = load i32, i32* %3
store i32 %78, i32* %4
store i32 0, i32* %8
br label %79
79: ; preds = %77, %69
%80 = load i32, i32* %3
%81 = add nsw i32 %80, 1
store i32 %81, i32* %3
br label %60
82: ; preds = %67
%83 = load i32*, i32** %15
%84 = call i32 (i32*, i8*, ...) @fscanf(i32* %83, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %14)
%85 = load i32*, i32** %15
%86 = load i32, i32* %4
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %87
%89 = call i32 (i32*, i8*, ...) @fscanf(i32* %85, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %88)
%90 = load i32, i32* %4
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %91
%93 = load i32, i32* %92
store i32 %93, i32* %9
%94 = load i32, i32* %9
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %107
96: ; preds = %82
%97 = load i32, i32* %9
%98 = load i32, i32* %14
%99 = load i32, i32* %9
%100 = sdiv i32 %98, %99
%101 = mul nsw i32 %97, %100
%102 = load i32, i32* %4
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [10 x i32], [10 x i32]* %13, i64 0, i64 %103
%105 = load i32, i32* %104
%106 = sub nsw i32 %105, %101
store i32 %106, i32* %104
br label %107
107: ; preds = %96, %82
store i32 0, i32* %3
br label %108
108: ; preds = %152, %107
%109 = load i32, i32* %3
%110 = load i32, i32* %4
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %111
%113 = load i32, i32* %112
%114 = icmp slt i32 %109, %113
br i1 %114, label %115, label %155
115: ; preds = %108
%116 = load i32*, i32** %15
%117 = getelementptr inbounds [14 x i8], [14 x i8]* %12, i64 0, i64 0
%118 = call i32 (i32*, i8*, ...) @fscanf(i32* %116, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %117)
store i32 0, i32* %6
store i32 1, i32* %8
br label %119
119: ; preds = %148, %115
%120 = load i32, i32* %6
%121 = load i32, i32* %2
%122 = icmp slt i32 %120, %121
br i1 %122, label %123, label %126
123: ; preds = %119
%124 = load i32, i32* %8
%125 = icmp ne i32 %124, 0
br label %126
126: ; preds = %123, %119
%127 = phi i1 [ false, %119 ], [ %125, %123 ]
br i1 %127, label %128, label %151
128: ; preds = %126
%129 = getelementptr inbounds [14 x i8], [14 x i8]* %12, i64 0, i64 0
%130 = load i32, i32* %6
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %131
%133 = load i8*, i8** %132
%134 = call i32 @strcmp(i8* %129, i8* %133)
%135 = icmp ne i32 %134, 0
br i1 %135, label %148, label %136
136: ; preds = %128
%137 = load i32, i32* %14
%138 = load i32, i32* %4
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %139
%141 = load i32, i32* %140
%142 = sdiv i32 %137, %141
%143 = load i32, i32* %6
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds [10 x i32], [10 x i32]* %13, i64 0, i64 %144
%146 = load i32, i32* %145
%147 = add nsw i32 %146, %142
store i32 %147, i32* %145
store i32 0, i32* %8
br label %148
148: ; preds = %136, %128
%149 = load i32, i32* %6
%150 = add nsw i32 %149, 1
store i32 %150, i32* %6
br label %119
151: ; preds = %126
br label %152
152: ; preds = %151
%153 = load i32, i32* %3
%154 = add nsw i32 %153, 1
store i32 %154, i32* %3
br label %108
155: ; preds = %108
%156 = load i32, i32* %7
%157 = add nsw i32 %156, 1
store i32 %157, i32* %7
br label %52
158: ; preds = %52
store i32 0, i32* %3
br label %159
159: ; preds = %174, %158
%160 = load i32, i32* %3
%161 = load i32, i32* %2
%162 = icmp slt i32 %160, %161
br i1 %162, label %163, label %177
163: ; preds = %159
%164 = load i32*, i32** %16
%165 = load i32, i32* %3
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %166
%168 = load i8*, i8** %167
%169 = load i32, i32* %3
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [10 x i32], [10 x i32]* %13, i64 0, i64 %170
%172 = load i32, i32* %171
%173 = call i32 @fprintf(i32* %164, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %168, i32 %172)
br label %174
174: ; preds = %163
%175 = load i32, i32* %3
%176 = add nsw i32 %175, 1
store i32 %176, i32* %3
br label %159
177: ; preds = %159
%178 = load i32*, i32** %15
%179 = call i32 @fclose(i32* %178)
%180 = load i32*, i32** %16
%181 = call i32 @fclose(i32* %180)
%182 = load i32, i32* %1
ret i32 %182
}

LLVM IR (-O2):
@.str = [9 x i8] c"gift1.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"gift1.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [7 x i8] c"%s %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca [10 x i8*]
%4 = alloca [14 x i8]
%5 = alloca [14 x i8]
%6 = alloca [10 x i32]
%7 = bitcast [10 x i32]* %6 to i8*
%8 = alloca i32
%9 = bitcast i32* %1 to i8*
%10 = bitcast [10 x i32]* %2 to i8*
%11 = bitcast [10 x i8*]* %3 to i8*
%12 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [14 x i8], [14 x i8]* %5, i64 0, i64 0
%14 = bitcast i32* %8 to i8*
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %117
20: ; preds = %0
%21 = zext i32 %18 to i64
%22 = shl nuw nsw i64 %21, 2
br label %25
23: ; preds = %25
%24 = icmp sgt i32 %31, 0
br i1 %24, label %36, label %117
25: ; preds = %20, %25
%26 = phi i64 [ 0, %20 ], [ %30, %25 ]
%27 = call dereferenceable_or_null(14) i8* @malloc(i32 14)
%28 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %26
store i8* %27, i8** %28
%29 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %27)
%30 = add nuw nsw i64 %26, 1
%31 = load i32, i32* %1
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %25, label %23
34: ; preds = %102
%35 = icmp sgt i32 %103, 0
br i1 %35, label %106, label %117
36: ; preds = %23, %102
%37 = phi i32 [ %57, %102 ], [ 0, %23 ]
%38 = phi i32 [ %104, %102 ], [ 0, %23 ]
%39 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%40 = load i32, i32* %1
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %56
42: ; preds = %36
%43 = zext i32 %40 to i64
br label %44
44: ; preds = %42, %44
%45 = phi i64 [ 0, %42 ], [ %53, %44 ]
%46 = phi i32 [ %37, %42 ], [ %52, %44 ]
%47 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %45
%48 = load i8*, i8** %47
%49 = call i32 @strcmp(i8* %12, i8* dereferenceable(1) %48)
%50 = icmp eq i32 %49, 0
%51 = trunc i64 %45 to i32
%52 = select i1 %50, i32 %51, i32 %46
%53 = add nuw nsw i64 %45, 1
%54 = icmp uge i64 %53, %43
%55 = or i1 %50, %54
br i1 %55, label %56, label %44
56: ; preds = %44, %36
%57 = phi i32 [ %37, %36 ], [ %52, %44 ]
%58 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %59
%61 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %60)
%62 = load i32, i32* %60
%63 = icmp eq i32 %62, 0
br i1 %63, label %72, label %64
64: ; preds = %56
%65 = load i32, i32* %8
%66 = srem i32 %65, %62
%67 = sub i32 %66, %65
%68 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %59
%69 = load i32, i32* %68
%70 = add i32 %67, %69
store i32 %70, i32* %68
%71 = icmp sgt i32 %62, 0
br i1 %71, label %74, label %72
72: ; preds = %56, %64
%73 = load i32, i32* %1
br label %102
74: ; preds = %64, %98
%75 = phi i32 [ %99, %98 ], [ 0, %64 ]
%76 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %13)
%77 = load i32, i32* %1
%78 = icmp sgt i32 %77, 0
br i1 %78, label %79, label %98
79: ; preds = %74
%80 = load i32, i32* %8
%81 = zext i32 %77 to i64
br label %82
82: ; preds = %79, %94
%83 = phi i64 [ 0, %79 ], [ %95, %94 ]
%84 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %83
%85 = load i8*, i8** %84
%86 = call i32 @strcmp(i8* %13, i8* dereferenceable(1) %85)
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %94
88: ; preds = %82
%89 = load i32, i32* %60
%90 = sdiv i32 %80, %89
%91 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %83
%92 = load i32, i32* %91
%93 = add nsw i32 %92, %90
store i32 %93, i32* %91
br label %98
94: ; preds = %82
%95 = add nuw nsw i64 %83, 1
%96 = icmp uge i64 %95, %81
%97 = or i1 %87, %96
br i1 %97, label %98, label %82
98: ; preds = %94, %88, %74
%99 = add nuw nsw i32 %75, 1
%100 = load i32, i32* %60
%101 = icmp slt i32 %99, %100
br i1 %101, label %74, label %102
102: ; preds = %98, %72
%103 = phi i32 [ %73, %72 ], [ %77, %98 ]
%104 = add nuw nsw i32 %38, 1
%105 = icmp slt i32 %104, %103
br i1 %105, label %36, label %34
106: ; preds = %34, %106
%107 = phi i64 [ %113, %106 ], [ 0, %34 ]
%108 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %107
%109 = load i8*, i8** %108
%110 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %107
%111 = load i32, i32* %110
%112 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %109, i32 %111)
%113 = add nuw nsw i64 %107, 1
%114 = load i32, i32* %1
%115 = sext i32 %114 to i64
%116 = icmp slt i64 %113, %115
br i1 %116, label %106, label %117
117: ; preds = %106, %0, %23, %34
%118 = call i32 @fclose(i32* %15)
%119 = call i32 @fclose(i32* %16)
ret i32 0
}