#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 IFNAMSIZ;
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int hwtstamp_config_set(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char ifname[IFNAMSIZ];
  int ret, cmd;
  if (argc != 3 || (strlen(argv[1]) >= IFNAMSIZ)) {
    usage();
    return 2;
  }
  strcpy(ifname, argv[1]);
  cmd = atoi(argv[2]);
  if (cmd != 0 && cmd != 1) {
    usage();
    return 2;
  }
  switch (cmd) {
  case 0:
    ret = hwtstamp_config_set(ifname, 0, 0);
    if (ret < 0) {
      fprintf(stderr, "hwtstamp_config_set() error\n");
      return 1;
    }
    break;
  case 1:
    ret = hwtstamp_config_set(ifname, 0, 1);
    if (ret < 0) {
      fprintf(stderr, "hwtstamp_config_set() error\n");
      return 1;
    }
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11c8 <main+0x68>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
mov    0x2e18(%rip),%rcx
cmp    (%rcx),%eax
jl     11e2 <main+0x82>
mov    $0x0,%al
call   1070 <usage@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    12f4 <main+0x194>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1231 <main+0xd1>
cmpl   $0x1,-0x28(%rbp)
je     1231 <main+0xd1>
mov    $0x0,%al
call   1070 <usage@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    12f4 <main+0x194>
mov    -0x28(%rbp),%eax
mov    %eax,-0x3c(%rbp)
test   %eax,%eax
je     1255 <main+0xf5>
jmp    1244 <main+0xe4>
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
je     129c <main+0x13c>
jmp    12e6 <main+0x186>
mov    -0x38(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <hwtstamp_config_set@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1297 <main+0x137>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
lea    0xd81(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    12f4 <main+0x194>
jmp    12e6 <main+0x186>
mov    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <hwtstamp_config_set@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    12e1 <main+0x181>
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
lea    0xd37(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    12f4 <main+0x194>
jmp    12e6 <main+0x186>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e67(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmp    $0x3,%edi
jne    11cd <main+0x6d>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1050 <strlen@plt>
cmp    (%r15),%eax
jge    11cd <main+0x6d>
mov    0x8(%r14),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    0x10(%r14),%rdi
call   1080 <atoi@plt>
cmp    $0x2,%eax
jae    11cd <main+0x6d>
xor    %r14d,%r14d
cmp    $0x1,%eax
je     11e8 <main+0x88>
test   %eax,%eax
jne    11da <main+0x7a>
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
jmp    11f2 <main+0x92>
xor    %eax,%eax
call   1070 <usage@plt>
mov    $0x2,%r14d
mov    %r14d,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <hwtstamp_config_set@plt>
test   %eax,%eax
jns    11da <main+0x7a>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%r14d
jmp    11da <main+0x7a>

LLVM IR (-O0):
@IFNAMSIZ = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"hwtstamp_config_set() error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @IFNAMSIZ
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %24, label %17
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strlen(i8* %20)
%22 = load i32, i32* @IFNAMSIZ
%23 = icmp sge i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %17, %2
%25 = call i32 (...) @usage()
store i32 2, i32* %3
store i32 1, i32* %10
br label %61
26: ; preds = %17
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strcpy(i8* %14, i8* %29)
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %26
%38 = load i32, i32* %9
%39 = icmp ne i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (...) @usage()
store i32 2, i32* %3
store i32 1, i32* %10
br label %61
42: ; preds = %37, %26
%43 = load i32, i32* %9
switch i32 %43, label %60 [
i32 0, label %44
i32 1, label %52
]
44: ; preds = %42
%45 = call i32 @hwtstamp_config_set(i8* %14, i32 0, i32 0)
store i32 %45, i32* %8
%46 = load i32, i32* %8
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %10
br label %61
51: ; preds = %44
br label %60
52: ; preds = %42
%53 = call i32 @hwtstamp_config_set(i8* %14, i32 0, i32 1)
store i32 %53, i32* %8
%54 = load i32, i32* %8
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %52
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %10
br label %61
59: ; preds = %52
br label %60
60: ; preds = %42, %59, %51
store i32 0, i32* %3
store i32 1, i32* %10
br label %61
61: ; preds = %60, %56, %48, %40, %24
%62 = load i8*, i8** %6
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@IFNAMSIZ = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"hwtstamp_config_set() error\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @IFNAMSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = icmp eq i32 %0, 3
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %9)
%11 = load i32, i32* @IFNAMSIZ
%12 = icmp slt i32 %10, %11
br i1 %12, label %15, label %13
13: ; preds = %7, %2
%14 = tail call i32 (...) @usage()
br label %37
15: ; preds = %7
%16 = load i8*, i8** %8
%17 = call i32 @strcpy(i8* %5, i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
%21 = icmp ult i32 %20, 2
br i1 %21, label %24, label %22
22: ; preds = %15
%23 = call i32 (...) @usage()
br label %37
24: ; preds = %15
switch i32 %20, label %37 [
i32 0, label %25
i32 1, label %31
]
25: ; preds = %24
%26 = call i32 @hwtstamp_config_set(i8* %5, i32 0, i32 0)
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %37
31: ; preds = %24
%32 = call i32 @hwtstamp_config_set(i8* %5, i32 0, i32 1)
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %24, %25, %31, %34, %28, %22, %13
%38 = phi i32 [ 2, %13 ], [ 2, %22 ], [ 1, %34 ], [ 1, %28 ], [ 0, %31 ], [ 0, %25 ], [ 0, %24 ]
ret i32 %38
}