#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 */
struct ip_user_dict {
  int dummy;
};
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ _IOLBF;
scalar_t__ dict_lookup(struct ip_user_dict *, char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
struct ip_user_dict *load_dict(int /*<<< orphan*/ *);
char *optarg;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
char *strchr(char *, char);
char *strtok(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  FILE *FH;
  char *filename = NULL;
  char *program_name = argv[0];
  char *cp;
  char *username, *address;
  char line[1024];
  struct ip_user_dict *current_entry;
  int ch;
  setvbuf(stdout, NULL, _IOLBF, 0);
  while ((ch = getopt(argc, argv, "f:")) != -1) {
    switch (ch) {
    case 'f':
      filename = optarg;
      break;
    default:
      usage(program_name);
      exit(1);
    }
  }
  if (filename == NULL) {
    usage(program_name);
    exit(1);
  }
  FH = fopen(filename, "r");
  current_entry = load_dict(FH);
  while (fgets(line, sizeof(line), stdin)) {
    if ((cp = strchr(line, '\n')) != NULL) {
      *cp = '\0';
    }
    if ((cp = strtok(line, " \t")) != NULL) {
      address = cp;
      username = strtok(NULL, " \t");
    } else {
      fprintf(stderr, "helper: unable to read tokens\n");
      printf("ERR\n");
      continue;
    }
    if ((dict_lookup(current_entry, username, address)) != 0) {
      printf("OK\n");
    } else {
      printf("ERR\n");
    }
  }
  fclose(FH);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
mov    0x2dbc(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   10a0 <setvbuf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdd9(%rip),%rdx
call   10d0 <getopt@plt>
mov    %eax,-0x44c(%rbp)
cmp    $0xffffffff,%eax
je     127a <main+0xaa>
mov    -0x44c(%rbp),%eax
sub    $0x66,%eax
jne    1262 <main+0x92>
jmp    124f <main+0x7f>
mov    0x2da2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1275 <main+0xa5>
mov    -0x28(%rbp),%rdi
call   1090 <usage@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1219 <main+0x49>
cmpq   $0x0,-0x20(%rbp)
jne    1298 <main+0xc8>
mov    -0x28(%rbp),%rdi
call   1090 <usage@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xd60(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <load_dict@plt>
mov    %rax,-0x448(%rbp)
lea    -0x440(%rbp),%rdi
mov    0x2d16(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     13ae <main+0x1de>
lea    -0x440(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1306 <main+0x136>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x440(%rbp),%rdi
lea    0xcf1(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1348 <main+0x178>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xccb(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x38(%rbp)
jmp    136e <main+0x19e>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
lea    0xcb0(%rip),%rsi
call   1080 <fprintf@plt>
lea    0xcc3(%rip),%rdi
call   1060 <printf@plt>
jmp    12bc <main+0xec>
mov    -0x448(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   10e0 <dict_lookup@plt>
cmp    $0x0,%rax
je     139d <main+0x1cd>
lea    0xc99(%rip),%rdi
call   1060 <printf@plt>
jmp    13a9 <main+0x1d9>
lea    0xc83(%rip),%rdi
call   1060 <printf@plt>
jmp    12bc <main+0xec>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%r14
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    0x2dcf(%rip),%rax
mov    (%rax),%edx
xor    %r15d,%r15d
xor    %esi,%esi
xor    %ecx,%ecx
call   10a0 <setvbuf@plt>
lea    0xdf2(%rip),%r12
mov    0x2de3(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10d0 <getopt@plt>
cmp    $0x66,%eax
jne    1238 <main+0x68>
mov    0x0(%r13),%r15
jmp    1220 <main+0x50>
cmp    $0xffffffff,%eax
jne    1341 <main+0x171>
test   %r15,%r15
je     1341 <main+0x171>
lea    0xdb2(%rip),%rsi
mov    %r15,%rdi
call   10b0 <fopen@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1050 <load_dict@plt>
mov    %rax,%r15
mov    0x2d70(%rip),%r14
mov    (%r14),%edx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     1323 <main+0x153>
lea    0x10(%rsp),%rbx
lea    0xd6e(%rip),%r12
lea    0xd89(%rip),%r13
jmp    12d2 <main+0x102>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
lea    0xd58(%rip),%rsi
call   1080 <fprintf@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     1323 <main+0x153>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     12e7 <main+0x117>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <strtok@plt>
test   %rax,%rax
je     12a0 <main+0xd0>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
mov    %r15,%rdi
mov    %rax,%rsi
mov    %rbp,%rdx
call   10e0 <dict_lookup@plt>
mov    %r13,%rdi
test   %rax,%rax
je     12b8 <main+0xe8>
lea    0xd0a(%rip),%rdi
jmp    12b8 <main+0xe8>
mov    0x8(%rsp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
call   1090 <usage@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.ip_user_dict = type { i32 }
@stdout = global i32 0
@_IOLBF = global i32 0
@.str = [3 x i8] c"f:\00"
@optarg = global i8* null
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c" \09\00"
@stderr = global i32 0
@.str.3 = [31 x i8] c"helper: unable to read tokens\0A\00"
@.str.4 = [5 x i8] c"ERR\0A\00"
@.str.5 = [4 x i8] c"OK\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [1024 x i8]
%13 = alloca %struct.ip_user_dict*
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
store i8* %17, i8** %8
%18 = load i32, i32* @stdout
%19 = load i32, i32* @_IOLBF
%20 = call i32 @setvbuf(i32 %18, i32* null, i32 %19, i32 0)
br label %21
21: ; preds = %34, %2
%22 = load i32, i32* %4
%23 = load i8**, i8*** %5
%24 = call i32 @getopt(i32 %22, i8** %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %24, i32* %14
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %35
26: ; preds = %21
%27 = load i32, i32* %14
switch i32 %27, label %30 [
i32 102, label %28
]
28: ; preds = %26
%29 = load i8*, i8** @optarg
store i8* %29, i8** %7
br label %34
30: ; preds = %26
%31 = load i8*, i8** %8
%32 = call i32 @usage(i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %28
br label %21
35: ; preds = %21
%36 = load i8*, i8** %7
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i8*, i8** %8
%40 = call i32 @usage(i8* %39)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %35
%43 = load i8*, i8** %7
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %44, i32** %6
%45 = load i32*, i32** %6
%46 = call %struct.ip_user_dict* @load_dict(i32* %45)
store %struct.ip_user_dict* %46, %struct.ip_user_dict** %13
br label %47
47: ; preds = %79, %65, %42
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%49 = load i32, i32* @stdin
%50 = call i64 @fgets(i8* %48, i32 1024, i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %80
52: ; preds = %47
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%54 = call i8* @strchr(i8* %53, i8 signext 10)
store i8* %54, i8** %9
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %58
56: ; preds = %52
%57 = load i8*, i8** %9
store i8 0, i8* %57
br label %58
58: ; preds = %56, %52
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%60 = call i8* @strtok(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %60, i8** %9
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = load i8*, i8** %9
store i8* %63, i8** %11
%64 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %64, i8** %10
br label %69
65: ; preds = %58
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%68 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %47
69: ; preds = %62
%70 = load %struct.ip_user_dict*, %struct.ip_user_dict** %13
%71 = load i8*, i8** %10
%72 = load i8*, i8** %11
%73 = call i64 @dict_lookup(%struct.ip_user_dict* %70, i8* %71, i8* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %69
%76 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %79
77: ; preds = %69
%78 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %79
79: ; preds = %77, %75
br label %47
80: ; preds = %47
%81 = load i32*, i32** %6
%82 = call i32 @fclose(i32* %81)
ret i32 0
}

LLVM IR (-O2):
%struct.ip_user_dict = type { i32 }
@stdout = global i32 0
@_IOLBF = global i32 0
@.str = [3 x i8] c"f:\00"
@optarg = global i8* null
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c" \09\00"
@stderr = global i32 0
@.str.3 = [31 x i8] c"helper: unable to read tokens\0A\00"
@str.6 = [4 x i8] c"ERR\00"
@str.7 = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1024 x i8]
%4 = load i8*, i8** %1
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IOLBF
%8 = tail call i32 @setvbuf(i32 %6, i32* null, i32 %7, i32 0)
br label %9
9: ; preds = %12, %2
%10 = phi i8* [ null, %2 ], [ %13, %12 ]
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %11, label %14 [
i32 -1, label %17
i32 102, label %12
]
12: ; preds = %9
%13 = load i8*, i8** @optarg
br label %9
14: ; preds = %9
%15 = tail call i32 @usage(i8* %4)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %9
%18 = icmp eq i8* %10, null
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = tail call i32 @usage(i8* %4)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %17
%23 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call %struct.ip_user_dict* @load_dict(i32* %23)
%25 = load i32, i32* @stdin
%26 = call i64 @fgets(i8* %5, i32 1024, i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %49, label %28
28: ; preds = %22, %43
%29 = call i8* @strchr(i8* %5, i8 signext 10)
%30 = icmp eq i8* %29, null
br i1 %30, label %32, label %31
31: ; preds = %28
store i8 0, i8* %29
br label %32
32: ; preds = %31, %28
%33 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %40, label %35
35: ; preds = %32
%36 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%37 = call i64 @dict_lookup(%struct.ip_user_dict* %24, i8* %36, i8* %33)
%38 = icmp eq i64 %37, 0
%39 = select i1 %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.7, i64 0, i64 0)
br label %43
40: ; preds = %32
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %35, %40
%44 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.6, i64 0, i64 0), %40 ], [ %39, %35 ]
%45 = call i32 @puts(i8* dereferenceable(1) %44)
%46 = load i32, i32* @stdin
%47 = call i64 @fgets(i8* %5, i32 1024, i32 %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %28
49: ; preds = %43, %22
%50 = call i32 @fclose(i32* %23)
ret i32 0
}