#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int fd;
  if (argc != 2)
    exit(EXIT_SUCCESS);
  sscanf(argv[1], "%d", &fd);
  if (write(fd, "test\0", 5) == -1)
    ;
  close(fd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116e <main+0x2e>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe83(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x14(%rbp),%edi
lea    0xe73(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    11a8 <main+0x68>
jmp    11a8 <main+0x68>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    1179 <main+0x39>
mov    0x8(%rsi),%rdi
lea    0xeaf(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0x4(%rsp),%edi
lea    0xe9d(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    0x4(%rsp),%edi
call   1040 <close@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"test\00\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @EXIT_SUCCESS
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%17 = load i32, i32* %6
%18 = call i32 @write(i32 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %12
br label %21
21: ; preds = %20, %12
%22 = load i32, i32* %6
%23 = call i32 @close(i32 %22)
%24 = load i32, i32* @EXIT_SUCCESS
%25 = call i32 @exit(i32 %24)
unreachable
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"test\00\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @EXIT_SUCCESS
%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 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = call i32 @write(i32 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%15 = load i32, i32* %3
%16 = call i32 @close(i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
%18 = call i32 @exit(i32 %17)
unreachable
}