#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 fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
char *scan_cookie(char *, char **);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  char *items[2];
  char buf[4096], *p;
  int len = -1;
  if (argc != 2)
    return -1;
  char *field = argv[1];
  if ((len = fread(buf, 1, 4096, stdin)) > 0) {
    buf[len] = 0;
    p = buf;
    while ((p = scan_cookie(p, items)) != 0) {
      if (strcmp(items[0], field) == 0) {
        printf("%s", items[1]);
        return 0;
      }
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x102c(%rbp)
ff ff ff
cmpl   $0x2,-0x8(%rbp)
je     1179 <main+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <main+0xfb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x1038(%rbp)
lea    -0x1020(%rbp),%rdi
mov    0x2e52(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
mov    %eax,-0x102c(%rbp)
cmp    $0x0,%eax
jle    1234 <main+0xf4>
movslq -0x102c(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1028(%rbp)
mov    -0x1028(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <scan_cookie@plt>
mov    %rax,-0x1028(%rbp)
cmp    $0x0,%rax
je     122f <main+0xef>
mov    -0x20(%rbp),%rdi
mov    -0x1038(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    122a <main+0xea>
mov    -0x18(%rbp),%rsi
lea    0xde7(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123b <main+0xfb>
jmp    11d3 <main+0x93>
jmp    1234 <main+0xf4>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1018,%rsp
mov    $0xffffffff,%r14d
cmp    $0x2,%edi
jne    11c8 <main+0x88>
mov    0x8(%rsi),%rbx
mov    0x2e85(%rip),%rax
mov    (%rax),%ecx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
test   %eax,%eax
jle    11c8 <main+0x88>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <scan_cookie@plt>
test   %rax,%rax
je     11c8 <main+0x88>
mov    %rax,%rbp
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1190 <main+0x50>
mov    0x8(%rsp),%rsi
lea    0xe40(%rip),%rdi
call   1050 <printf@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i8*]
%7 = alloca [4096 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %9
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %3
br label %45
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %10
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%19 = load i32, i32* @stdin
%20 = call i32 @fread(i8* %18, i32 1, i32 4096, i32 %19)
store i32 %20, i32* %9
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %44
22: ; preds = %14
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
store i8* %26, i8** %8
br label %27
27: ; preds = %42, %22
%28 = load i8*, i8** %8
%29 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 0
%30 = call i8* @scan_cookie(i8* %28, i8** %29)
store i8* %30, i8** %8
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %43
32: ; preds = %27
%33 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 0
%34 = load i8*, i8** %33
%35 = load i8*, i8** %10
%36 = call i64 @strcmp(i8* %34, i8* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %32
%39 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %40)
store i32 0, i32* %3
br label %45
42: ; preds = %32
br label %27
43: ; preds = %27
br label %44
44: ; preds = %43, %14
store i32 -1, i32* %3
br label %45
45: ; preds = %44, %38, %13
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i8*]
%4 = alloca [4096 x i8]
%5 = bitcast [2 x i8*]* %3 to i8*
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %30
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i32, i32* @stdin
%12 = call i32 @fread(i8* %6, i32 1, i32 4096, i32 %11)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %8
%15 = zext i32 %12 to i64
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %15
store i8 0, i8* %16
%17 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
br label %18
18: ; preds = %22, %14
%19 = phi i8* [ %6, %14 ], [ %20, %22 ]
%20 = call i8* @scan_cookie(i8* %19, i8** %17)
%21 = icmp eq i8* %20, null
br i1 %21, label %30, label %22
22: ; preds = %18
%23 = load i8*, i8** %17
%24 = call i64 @strcmp(i8* %23, i8* %10)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %18
26: ; preds = %22
%27 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %18, %26, %8, %2
%31 = phi i32 [ -1, %2 ], [ 0, %26 ], [ -1, %8 ], [ -1, %18 ]
ret i32 %31
}