#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_forward_delay(char *const, struct timeval *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int);
scalar_t__ strtotimeval(struct timeval *, char *const);
int br_cmd_setfd(int argc, char *const *argv) {
  struct timeval tv;
  int err;
  if (strtotimeval(&tv, argv[2])) {
    fprintf(stderr, "bad forward delay value\n");
    return 1;
  }
  err = br_set_bridge_forward_delay(argv[1], &tv);
  if (err)
    fprintf(stderr, "set forward delay failed: %s\n", strerror(err));
  return err != 0;
}


x86 assembly (clang, -O0):
<br_cmd_setfd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x18(%rbp),%rdi
call   1050 <strtotimeval@plt>
cmp    $0x0,%rax
je     118d <br_cmd_setfd+0x4d>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e2 <br_cmd_setfd+0xa2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <br_set_bridge_forward_delay@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11d3 <br_cmd_setfd+0x93>
mov    0x2e2e(%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    0xe4d(%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_setfd>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x10(%rsi),%rsi
mov    %rsp,%rdi
call   1050 <strtotimeval@plt>
test   %rax,%rax
je     1175 <br_cmd_setfd+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_setfd+0x71>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1030 <br_set_bridge_forward_delay@plt>
mov    %eax,%ebx
test   %eax,%eax
je     11aa <br_cmd_setfd+0x6a>
mov    0x2e52(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1060 <strerror@plt>
lea    0xe7b(%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 = [25 x i8] c"bad forward delay value\0A\00"
@.str.1 = [30 x i8] c"set forward delay failed: %s\0A\00"
define i32 @br_cmd_setfd(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 2
%10 = load i8*, i8** %9
%11 = call i64 @strtotimeval(%struct.timeval* %6, i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %32
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @br_set_bridge_forward_delay(i8* %19, %struct.timeval* %6)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = load i32, i32* %7
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %23, %16
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i32
store i32 %31, i32* %3
br label %32
32: ; preds = %28, %13
%33 = load i32, i32* %3
ret i32 %33
}

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