#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*/ SYS_syslog;
int atoi(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ syscall(int /*<<< orphan*/, int, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  int level;
  if (argc == 2) {
    level = atoi(argv[1]);
  } else {
    fprintf(stderr, "%s: need a single arg\n", argv[0]);
    exit(1);
  }
  if (syscall(SYS_syslog, 8, NULL, level) < 0) {
    fprintf(stderr, "%s: syslog(setlevel): %s\n", argv[0], strerror(errno));
    exit(1);
  }
  exit(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   $0x2,-0x8(%rbp)
jne    1185 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    11ad <main+0x5d>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%ecx
mov    $0x8,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <syscall@plt>
cmp    $0x0,%rax
jge    1218 <main+0xc8>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11ba <main+0x6a>
mov    0x8(%rbx),%rdi
call   1050 <atoi@plt>
mov    0x2e8d(%rip),%rcx
mov    (%rcx),%edi
mov    $0x8,%esi
xor    %edx,%edx
mov    %eax,%ecx
call   1040 <syscall@plt>
test   %rax,%rax
jns    11de <main+0x8e>
mov    0x2e51(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%rbx
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe76(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe33(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"%s: need a single arg\0A\00"
@SYS_syslog = global i32 0
@.str.1 = [26 x i8] c"%s: syslog(setlevel): %s\0A\00"
@errno = global i32 0
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 eq i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %6
br label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %9
%22 = load i32, i32* @SYS_syslog
%23 = load i32, i32* %6
%24 = call i64 @syscall(i32 %22, i32 8, i32* null, i32 %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %21
%36 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"%s: need a single arg\0A\00"
@SYS_syslog = global i32 0
@.str.1 = [26 x i8] c"%s: syslog(setlevel): %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = load i32, i32* @SYS_syslog
%9 = tail call i64 @syscall(i32 %8, i32 8, i32* null, i32 %7)
%10 = icmp slt i64 %9, 0
br i1 %10, label %16, label %23
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %4
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %20)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %4
%24 = tail call i32 @exit(i32 0)
unreachable
}