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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ do_main_record(char *);
int /*<<< orphan*/ do_purchasing_card(char *);
int /*<<< orphan*/ do_purchasing_card_item(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int main(int argc, char **argv) {
  char line[300 + 1];
  FILE *fp;
  if (argc < 2)
    exit(EXIT_FAILURE);
  fp = fopen(argv[1], "r");
  while (fgets(line, sizeof(line), fp) != NULL) {
    if (line[2] == 'S' || line[2] == 'R')
      do_main_record(line);
    else if (line[3] == ' ')
      do_purchasing_card(line);
    else if (line[3] == '0' || line[3] == '1')
      do_purchasing_card_item(line);
  }
  fclose(fp);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a1 <main+0x31>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe50(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x148(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%rdx
mov    $0x12d,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     126b <main+0xfb>
movsbl -0x13e(%rbp),%eax
cmp    $0x53,%eax
je     11fe <main+0x8e>
movsbl -0x13e(%rbp),%eax
cmp    $0x52,%eax
jne    120f <main+0x9f>
lea    -0x140(%rbp),%rdi
call   1050 <do_main_record@plt>
jmp    1266 <main+0xf6>
movsbl -0x13d(%rbp),%eax
cmp    $0x20,%eax
jne    1230 <main+0xc0>
lea    -0x140(%rbp),%rdi
call   1070 <do_purchasing_card@plt>
jmp    1261 <main+0xf1>
movsbl -0x13d(%rbp),%eax
cmp    $0x30,%eax
je     1250 <main+0xe0>
movsbl -0x13d(%rbp),%eax
cmp    $0x31,%eax
jne    125c <main+0xec>
lea    -0x140(%rbp),%rdi
call   1040 <do_purchasing_card_item@plt>
jmp    1261 <main+0xf1>
jmp    1266 <main+0xf6>
jmp    11bc <main+0x4c>
mov    -0x148(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x138,%rsp
cmp    $0x1,%edi
jg     118d <main+0x1d>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x8(%rsi),%rdi
lea    0xe68(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x12d,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11cb <main+0x5b>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rsp,%rbx
jmp    11ed <main+0x7d>
mov    %rbx,%rdi
call   1050 <do_main_record@plt>
mov    %rbx,%rdi
mov    $0x12d,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11b5 <main+0x45>
movzbl 0x2(%rsp),%eax
and    $0xfe,%al
cmp    $0x52,%al
je     11d0 <main+0x60>
movzbl 0x3(%rsp),%eax
cmp    $0x20,%al
jne    1210 <main+0xa0>
mov    %rbx,%rdi
call   1070 <do_purchasing_card@plt>
jmp    11d8 <main+0x68>
nopl   0x0(%rax,%rax,1)
and    $0xfe,%al
cmp    $0x30,%al
jne    11d8 <main+0x68>
mov    %rbx,%rdi
call   1040 <do_purchasing_card_item@plt>
jmp    11d8 <main+0x68>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [2 x i8] c"r\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [301 x i8]
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %7
br label %18
18: ; preds = %59, %13
%19 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 0
%20 = load i32*, i32** %7
%21 = call i32* @fgets(i8* %19, i32 301, i32* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %60
23: ; preds = %18
%24 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 83
br i1 %27, label %33, label %28
28: ; preds = %23
%29 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 2
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 82
br i1 %32, label %33, label %36
33: ; preds = %28, %23
%34 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 0
%35 = call i32 @do_main_record(i8* %34)
br label %59
36: ; preds = %28
%37 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 3
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 32
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 0
%43 = call i32 @do_purchasing_card(i8* %42)
br label %58
44: ; preds = %36
%45 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 48
br i1 %48, label %54, label %49
49: ; preds = %44
%50 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 3
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 49
br i1 %53, label %54, label %57
54: ; preds = %49, %44
%55 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 0
%56 = call i32 @do_purchasing_card_item(i8* %55)
br label %57
57: ; preds = %54, %49
br label %58
58: ; preds = %57, %41
br label %59
59: ; preds = %58, %33
br label %18
60: ; preds = %18
%61 = load i32*, i32** %7
%62 = call i32 @fclose(i32* %61)
%63 = load i32, i32* @EXIT_SUCCESS
%64 = call i32 @exit(i32 %63)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [2 x i8] c"r\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [301 x i8]
%4 = getelementptr inbounds [301 x i8], [301 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32* @fgets(i8* %4, i32 301, i32* %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %37, label %15
15: ; preds = %9
%16 = getelementptr inbounds [301 x i8], [301 x i8]* %3, i64 0, i64 2
%17 = getelementptr inbounds [301 x i8], [301 x i8]* %3, i64 0, i64 3
br label %18
18: ; preds = %15, %34
%19 = load i8, i8* %16
%20 = and i8 %19, -2
%21 = icmp eq i8 %20, 82
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @do_main_record(i8* %4)
br label %34
24: ; preds = %18
%25 = load i8, i8* %17
%26 = icmp eq i8 %25, 32
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @do_purchasing_card(i8* %4)
br label %34
29: ; preds = %24
%30 = and i8 %25, -2
%31 = icmp eq i8 %30, 48
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @do_purchasing_card_item(i8* %4)
br label %34
34: ; preds = %27, %29, %32, %22
%35 = call i32* @fgets(i8* %4, i32 301, i32* %12)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %18
37: ; preds = %34, %9
%38 = call i32 @fclose(i32* %12)
%39 = load i32, i32* @EXIT_SUCCESS
%40 = call i32 @exit(i32 %39)
unreachable
}