#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 /*<<< orphan*/ O_APPEND;
int /*<<< orphan*/ add_fl(char **, int /*<<< orphan*/);
int /*<<< orphan*/ del_fl(char **, int /*<<< orphan*/);
int /*<<< orphan*/ err_quit(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ get_fl(char **);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    err_quit("usage: a.out <descriptor#>");
  }
  get_fl(&argv[1]);
  add_fl(&argv[1], O_APPEND);
  get_fl(&argv[1]);
  del_fl(&argv[1], O_APPEND);
  get_fl(&argv[1]);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117c <main+0x2c>
lea    0xe89(%rip),%rdi
call   1030 <err_quit@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1060 <get_fl@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
call   1070 <add_fl@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1060 <get_fl@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
call   1040 <del_fl@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1060 <get_fl@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1168 <main+0x18>
lea    0xe9d(%rip),%rdi
call   1030 <err_quit@plt>
add    $0x8,%rbx
mov    %rbx,%rdi
call   1060 <get_fl@plt>
mov    0x2e5d(%rip),%r14
mov    (%r14),%esi
mov    %rbx,%rdi
call   1070 <add_fl@plt>
mov    %rbx,%rdi
call   1060 <get_fl@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1040 <del_fl@plt>
mov    %rbx,%rdi
call   1060 <get_fl@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"usage: a.out <descriptor#>\00"
@O_APPEND = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @err_quit(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = call i32 @get_fl(i8** %12)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i32, i32* @O_APPEND
%17 = call i32 @add_fl(i8** %15, i32 %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = call i32 @get_fl(i8** %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i32, i32* @O_APPEND
%24 = call i32 @del_fl(i8** %22, i32 %23)
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = call i32 @get_fl(i8** %26)
%28 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [27 x i8] c"usage: a.out <descriptor#>\00"
@O_APPEND = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @err_quit(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = tail call i32 @get_fl(i8** %7)
%9 = load i32, i32* @O_APPEND
%10 = tail call i32 @add_fl(i8** %7, i32 %9)
%11 = tail call i32 @get_fl(i8** %7)
%12 = load i32, i32* @O_APPEND
%13 = tail call i32 @del_fl(i8** %7, i32 %12)
%14 = tail call i32 @get_fl(i8** %7)
%15 = tail call i32 @exit(i32 0)
unreachable
}