#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ syscall(int /*<<< orphan*/, int, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  int level;
  if (!argv[1])
    exit(0);
  level = atoi(argv[1]);
  if ((level < 1) || (level > 8)) {
    fprintf(stderr, "invalid log level %d\n", level);
    exit(-1);
  }
  if (!syscall(SYS_syslog, 8, NULL, level)) {
    exit(0);
  } else {
    perror("syslog");
    exit(-1);
  }
}


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)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    117c <main+0x2c>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     11a0 <main+0x50>
cmpl   $0x8,-0x14(%rbp)
jle    11c2 <main+0x72>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe4d(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%ecx
mov    $0x8,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <syscall@plt>
cmp    $0x0,%eax
jne    11ec <main+0x9c>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe23(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     11a5 <main+0x55>
call   1060 <atoi@plt>
mov    %eax,%ecx
add    $0xfffffff7,%ecx
cmp    $0xfffffff7,%ecx
ja     118a <main+0x3a>
mov    0x2e68(%rip),%rcx
mov    (%rcx),%edi
lea    0xe87(%rip),%rsi
mov    %eax,%edx
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    0x2e67(%rip),%rcx
mov    (%rcx),%edi
mov    $0x8,%esi
xor    %edx,%edx
mov    %eax,%ecx
call   1040 <syscall@plt>
test   %eax,%eax
jne    11ac <main+0x5c>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe63(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

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

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