#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
char *malloc(size_t);
int /*<<< orphan*/ printf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  FILE *f;
  size_t len = 1000;
  char *a = malloc(len);
  char *b = malloc(len);
  int c, cntr, cnt = 2;
  for (; cnt < argc; ++cnt) {
    f = fopen(argv[1], "r");
    for (c = 0; fscanf(f, "%s", a) != EOF; cntr = 0)
      if (strcmp(argv[cnt], a) == 0)
        for (++c; cntr < len;)
          b[cntr] = a[cntr++];
    printf("%s = %d\n", b, c);
    fclose(f);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x3e8,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x2,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1289 <main+0x129>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe46(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe29(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2e03(%rip),%rcx
cmp    (%rcx),%rax
je     125f <main+0xff>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    124e <main+0xee>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movslq -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1249 <main+0xe9>
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x38(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1216 <main+0xb6>
jmp    124e <main+0xee>
jmp    1253 <main+0xf3>
movl   $0x0,-0x38(%rbp)
jmp    11ca <main+0x6a>
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xd98(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    119f <main+0x3f>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,(%rsp)
cmp    $0x3,%ebp
jl     1273 <main+0x103>
mov    (%rsp),%rax
add    $0x1,%rax
mov    %rax,0x10(%rsp)
mov    %ebp,%eax
mov    %rax,0x8(%rsp)
mov    $0x2,%r12d
lea    0xe3a(%rip),%rbp
jmp    11f6 <main+0x86>
nopw   0x0(%rax,%rax,1)
lea    0xe2e(%rip),%rdi
mov    (%rsp),%rsi
mov    %r15d,%edx
call   1040 <printf@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
add    $0x1,%r12
cmp    0x8(%rsp),%r12
je     1273 <main+0x103>
mov    0x8(%r14),%rdi
lea    0xdff(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1050 <fscanf@plt>
xor    %r15d,%r15d
mov    0x2dc7(%rip),%rcx
cmp    (%rcx),%rax
je     11d0 <main+0x60>
xor    %r15d,%r15d
jmp    124a <main+0xda>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1050 <fscanf@plt>
mov    0x2da3(%rip),%rcx
cmp    (%rcx),%rax
je     11d0 <main+0x60>
mov    (%r14,%r12,8),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1230 <main+0xc0>
mov    $0x3e8,%edx
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <memcpy@plt>
add    $0x1,%r15d
jmp    1230 <main+0xc0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.2 = [9 x i8] c"%s = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1000, i64* %7
%13 = load i64, i64* %7
%14 = call i8* @malloc(i64 %13)
store i8* %14, i8** %8
%15 = load i64, i64* %7
%16 = call i8* @malloc(i64 %15)
store i8* %16, i8** %9
store i32 2, i32* %12
br label %17
17: ; preds = %69, %2
%18 = load i32, i32* %12
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %72
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %6
store i32 0, i32* %10
br label %26
26: ; preds = %62, %21
%27 = load i32*, i32** %6
%28 = load i8*, i8** %8
%29 = call i64 @fscanf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i64, i64* @EOF
%31 = icmp ne i64 %29, %30
br i1 %31, label %32, label %63
32: ; preds = %26
%33 = load i8**, i8*** %5
%34 = load i32, i32* %12
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = load i8*, i8** %8
%39 = call i64 @strcmp(i8* %37, i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %61
41: ; preds = %32
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
store i32 %43, i32* %10
br label %44
44: ; preds = %49, %41
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = load i64, i64* %7
%48 = icmp ult i64 %46, %47
br i1 %48, label %49, label %60
49: ; preds = %44
%50 = load i8*, i8** %8
%51 = load i32, i32* %11
%52 = add nsw i32 %51, 1
store i32 %52, i32* %11
%53 = sext i32 %51 to i64
%54 = getelementptr inbounds i8, i8* %50, i64 %53
%55 = load i8, i8* %54
%56 = load i8*, i8** %9
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 %55, i8* %59
br label %44
60: ; preds = %44
br label %61
61: ; preds = %60, %32
br label %62
62: ; preds = %61
store i32 0, i32* %11
br label %26
63: ; preds = %26
%64 = load i8*, i8** %9
%65 = load i32, i32* %10
%66 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %64, i32 %65)
%67 = load i32*, i32** %6
%68 = call i32 @fclose(i32* %67)
br label %69
69: ; preds = %63
%70 = load i32, i32* %12
%71 = add nsw i32 %70, 1
store i32 %71, i32* %12
br label %17
72: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.2 = [9 x i8] c"%s = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call dereferenceable_or_null(1000) i8* @malloc(i64 1000)
%4 = tail call dereferenceable_or_null(1000) i8* @malloc(i64 1000)
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %37
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = getelementptr i8, i8* %4, i64 1
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %6, %31
%11 = phi i64 [ 2, %6 ], [ %35, %31 ]
%12 = load i8*, i8** %7
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = tail call i64 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %31, label %17
17: ; preds = %10
%18 = getelementptr inbounds i8*, i8** %1, i64 %11
br label %19
19: ; preds = %17, %26
%20 = phi i32 [ 0, %17 ], [ %27, %26 ]
%21 = load i8*, i8** %18
%22 = tail call i64 @strcmp(i8* %21, i8* %3)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = add nsw i32 %20, 1
br label %26
26: ; preds = %24, %19
%27 = phi i32 [ %20, %19 ], [ %25, %24 ]
%28 = tail call i64 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%29 = load i64, i64* @EOF
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %19
31: ; preds = %26, %10
%32 = phi i32 [ 0, %10 ], [ %27, %26 ]
%33 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %4, i32 %32)
%34 = tail call i32 @fclose(i32* %13)
%35 = add nuw nsw i64 %11, 1
%36 = icmp eq i64 %35, %9
br i1 %36, label %37, label %10
37: ; preds = %31, %2
ret i32 0
}