#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 */
struct timeval {
  int dummy;
};

/* Variables and functions */
int br_set_bridge_hello_time(char *, struct timeval *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int);
scalar_t__ strtotimeval(struct timeval *, char *);
int br_cmd_sethello(char **argv) {
  struct timeval tv;
  int err;
  if (strtotimeval(&tv, argv[2])) {
    fprintf(stderr, "bad hello timer value\n");
    return 1;
  }
  err = br_set_bridge_hello_time(argv[1], &tv);
  if (err)
    fprintf(stderr, "set hello timer failed: %s\n", strerror(err));
  return err != 0;
}


x86 assembly (clang, -O0):
<br_cmd_sethello>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x18(%rbp),%rdi
call   1050 <strtotimeval@plt>
cmp    $0x0,%rax
je     118a <br_cmd_sethello+0x4a>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11df <br_cmd_sethello+0x9f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <br_set_bridge_hello_time@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11d0 <br_cmd_sethello+0x90>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<br_cmd_sethello>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x10(%rdi),%rsi
mov    %rsp,%rdi
call   1050 <strtotimeval@plt>
test   %rax,%rax
je     1175 <br_cmd_sethello+0x35>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    11b1 <br_cmd_sethello+0x71>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1030 <br_set_bridge_hello_time@plt>
mov    %eax,%ebx
test   %eax,%eax
je     11aa <br_cmd_sethello+0x6a>
mov    0x2e52(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1060 <strerror@plt>
lea    0xe79(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"bad hello timer value\0A\00"
@.str.1 = [28 x i8] c"set hello timer failed: %s\0A\00"
define i32 @br_cmd_sethello(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca %struct.timeval
%5 = alloca i32
store i8** %0, i8*** %3
%6 = load i8**, i8*** %3
%7 = getelementptr inbounds i8*, i8** %6, i64 2
%8 = load i8*, i8** %7
%9 = call i64 @strtotimeval(%struct.timeval* %4, i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %30
14: ; preds = %1
%15 = load i8**, i8*** %3
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @br_set_bridge_hello_time(i8* %17, %struct.timeval* %4)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = load i32, i32* %5
%24 = call i8* @strerror(i32 %23)
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %21, %14
%27 = load i32, i32* %5
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i32
store i32 %29, i32* %2
br label %30
30: ; preds = %26, %11
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"bad hello timer value\0A\00"
@.str.1 = [28 x i8] c"set hello timer failed: %s\0A\00"
define i32 @br_cmd_sethello(i8** nocapture %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = getelementptr inbounds i8*, i8** %0, i64 2
%5 = load i8*, i8** %4
%6 = call i64 @strtotimeval(%struct.timeval* %2, i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %22
11: ; preds = %1
%12 = getelementptr inbounds i8*, i8** %0, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @br_set_bridge_hello_time(i8* %13, %struct.timeval* %2)
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = call i8* @strerror(i32 %14)
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %11
%21 = zext i1 %15 to i32
br label %22
22: ; preds = %20, %8
%23 = phi i32 [ 1, %8 ], [ %21, %20 ]
ret i32 %23
}