#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 get_fifo_capacity(char *);
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ set_fifo_capacity(char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int value, fd;
  char *filename, answer, *command;
  if (argc < 3) {
    print_help();
    return -1;
  }
  command = argv[1];
  filename = argv[2];
  if (strcmp(command, "set") == 0) {
    if (argc != 4) {
      print_help();
      return -1;
    }
    sscanf(argv[3], "%d", &value);
    printf("YOU SHOULDN'T USE THIS COMMAND IF THE FILENAME IS ALREADY OPEN\n");
    printf("filename: %s\n", filename);
    printf("new_value: %d\n", value);
    printf("Proceed? [Y|n]: ");
    scanf("%c", &answer);
    if (answer == 'Y' || answer == 'y' || answer == '\n') {
      set_fifo_capacity(filename, value);
      printf("DONE\n");
    } else {
      printf("Aborted\n");
    }
  } else if (strcmp(command, "get") == 0) {
    value = get_fifo_capacity(filename);
    printf("Capacity of %s is %d\n", filename, value);
  } else {
    print_help();
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11a3 <main+0x33>
mov    $0x0,%al
call   1090 <print_help@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1311 <main+0x1a1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12b2 <main+0x142>
cmpl   $0x4,-0x8(%rbp)
je     11f2 <main+0x82>
mov    $0x0,%al
call   1090 <print_help@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1311 <main+0x1a1>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe03(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1070 <sscanf@plt>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe25(%rip),%rdi
lea    -0x21(%rbp),%rsi
call   1080 <scanf@plt>
movsbl -0x21(%rbp),%eax
cmp    $0x59,%eax
je     1280 <main+0x110>
movsbl -0x21(%rbp),%eax
cmp    $0x79,%eax
je     1280 <main+0x110>
movsbl -0x21(%rbp),%eax
cmp    $0xa,%eax
jne    129f <main+0x12f>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <set_fifo_capacity@plt>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ad <main+0x13d>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    130a <main+0x19a>
mov    -0x30(%rbp),%rdi
lea    0xdca(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12f2 <main+0x182>
mov    -0x20(%rbp),%rdi
call   1030 <get_fifo_capacity@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <main+0x195>
mov    $0x0,%al
call   1090 <print_help@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1311 <main+0x1a1>
jmp    130a <main+0x19a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jle    1283 <main+0x103>
mov    %rsi,%rbp
mov    %edi,%ebx
mov    0x8(%rsi),%r15
mov    0x10(%rsi),%r14
lea    0xe5c(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11eb <main+0x6b>
lea    0xe80(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1283 <main+0x103>
mov    %r14,%rdi
call   1040 <get_fifo_capacity@plt>
lea    0xe64(%rip),%rdi
xor    %ebp,%ebp
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    128f <main+0x10f>
cmp    $0x4,%ebx
jne    1283 <main+0x103>
mov    0x18(%rbp),%rdi
lea    0xe05(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1080 <sscanf@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
lea    0xdeb(%rip),%rdi
xor    %ebp,%ebp
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde6(%rip),%rdi
lea    0x3(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x3(%rsp),%al
cmp    $0xa,%al
je     1269 <main+0xe9>
cmp    $0x79,%al
je     1269 <main+0xe9>
cmp    $0x59,%al
jne    129c <main+0x11c>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1060 <set_fifo_capacity@plt>
lea    0xe1d(%rip),%rdi
call   1030 <puts@plt>
jmp    128f <main+0x10f>
xor    %eax,%eax
call   10a0 <print_help@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
jmp    128f <main+0x10f>

LLVM IR (-O0):
@.str = [4 x i8] c"set\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [64 x i8] c"YOU SHOULDN'T USE THIS COMMAND IF THE FILENAME IS ALREADY OPEN\0A\00"
@.str.3 = [14 x i8] c"filename: %s\0A\00"
@.str.4 = [15 x i8] c"new_value: %d\0A\00"
@.str.5 = [17 x i8] c"Proceed? [Y|n]: \00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [6 x i8] c"DONE\0A\00"
@.str.8 = [9 x i8] c"Aborted\0A\00"
@.str.9 = [4 x i8] c"get\00"
@.str.10 = [22 x i8] c"Capacity of %s is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (...) @print_help()
store i32 -1, i32* %3
br label %75
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %10
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
store i8* %21, i8** %8
%22 = load i8*, i8** %10
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %61
25: ; preds = %15
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 4
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 (...) @print_help()
store i32 -1, i32* %3
br label %75
30: ; preds = %25
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0))
%36 = load i8*, i8** %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = load i32, i32* %6
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %9)
%42 = load i8, i8* %9
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 89
br i1 %44, label %53, label %45
45: ; preds = %30
%46 = load i8, i8* %9
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 121
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i8, i8* %9
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 10
br i1 %52, label %53, label %58
53: ; preds = %49, %45, %30
%54 = load i8*, i8** %8
%55 = load i32, i32* %6
%56 = call i32 @set_fifo_capacity(i8* %54, i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %60
58: ; preds = %49
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
br label %60
60: ; preds = %58, %53
br label %74
61: ; preds = %15
%62 = load i8*, i8** %10
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %61
%66 = load i8*, i8** %8
%67 = call i32 @get_fifo_capacity(i8* %66)
store i32 %67, i32* %6
%68 = load i8*, i8** %8
%69 = load i32, i32* %6
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* %68, i32 %69)
br label %73
71: ; preds = %61
%72 = call i32 (...) @print_help()
store i32 -1, i32* %3
br label %75
73: ; preds = %65
br label %74
74: ; preds = %73, %60
store i32 0, i32* %3
br label %75
75: ; preds = %74, %71, %28, %13
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@.str = [4 x i8] c"set\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"filename: %s\0A\00"
@.str.4 = [15 x i8] c"new_value: %d\0A\00"
@.str.5 = [17 x i8] c"Proceed? [Y|n]: \00"
@.str.6 = [3 x i8] c"%c\00"
@.str.9 = [4 x i8] c"get\00"
@.str.10 = [22 x i8] c"Capacity of %s is %d\0A\00"
@str = [63 x i8] c"YOU SHOULDN'T USE THIS COMMAND IF THE FILENAME IS ALREADY OPEN\00"
@str.11 = [8 x i8] c"Aborted\00"
@str.12 = [5 x i8] c"DONE\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i8
%5 = bitcast i32* %3 to i8*
%6 = icmp slt i32 %0, 3
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (...) @print_help()
br label %45
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %37
16: ; preds = %9
%17 = icmp eq i32 %0, 4
br i1 %17, label %20, label %18
18: ; preds = %16
%19 = tail call i32 (...) @print_help()
br label %45
20: ; preds = %16
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%30 = load i8, i8* %4
switch i8 %30, label %35 [
i8 121, label %31
i8 89, label %31
i8 10, label %31
]
31: ; preds = %20, %20, %20
%32 = load i32, i32* %3
%33 = call i32 @set_fifo_capacity(i8* %13, i32 %32)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
br label %45
35: ; preds = %20
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
br label %45
37: ; preds = %9
%38 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = tail call i32 @get_fifo_capacity(i8* %13)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* %13, i32 %41)
br label %45
43: ; preds = %37
%44 = tail call i32 (...) @print_help()
br label %45
45: ; preds = %40, %35, %31, %43, %18, %7
%46 = phi i32 [ -1, %7 ], [ -1, %18 ], [ -1, %43 ], [ 0, %31 ], [ 0, %35 ], [ 0, %40 ]
ret i32 %46
}