#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef void *uint32_t;
struct TYPE_2__ {
  void *data;
};
struct dtv_property {
  TYPE_1__ u;
  void *cmd;
};
struct dtv_properties {
  int num;
  struct dtv_property *props;
};

/* Variables and functions */
int /*<<< orphan*/ FE_SET_PROPERTY;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int ioctl(int, int /*<<< orphan*/, struct dtv_properties *);
int /*<<< orphan*/ stderr;
int set_property(int fd, uint32_t cmd, uint32_t data) {
  struct dtv_property p, *b;
  struct dtv_properties c;
  int ret;
  p.cmd = cmd;
  c.num = 1;
  c.props = &p;
  b = &p;
  b->u.data = data;
  ret = ioctl(fd, FE_SET_PROPERTY, &c);
  if (ret < 0) {
    fprintf(stderr, "FE_SET_PROPERTY returned %d\n", ret);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_property>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x40(%rbp)
lea    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1030 <ioctl@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    11a3 <set_property+0x83>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <set_property+0x8a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_property>:
sub    $0x28,%rsp
mov    %rsi,0x20(%rsp)
movl   $0x1,0x8(%rsp)
lea    0x18(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    %rdx,0x18(%rsp)
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
call   1030 <ioctl@plt>
xor    %ecx,%ecx
test   %eax,%eax
jns    1175 <set_property+0x55>
mov    0x2e80(%rip),%rcx
mov    (%rcx),%edi
lea    0xe97(%rip),%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    $0xffffffff,%ecx
mov    %ecx,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.dtv_property = type { %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.dtv_properties = type { i32, %struct.dtv_property* }
@FE_SET_PROPERTY = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"FE_SET_PROPERTY returned %d\0A\00"
define i32 @set_property(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.dtv_property
%9 = alloca %struct.dtv_property*
%10 = alloca %struct.dtv_properties
%11 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%12 = load i8*, i8** %6
%13 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %8, i32 0, i32 1
store i8* %12, i8** %13
%14 = getelementptr inbounds %struct.dtv_properties, %struct.dtv_properties* %10, i32 0, i32 0
store i32 1, i32* %14
%15 = getelementptr inbounds %struct.dtv_properties, %struct.dtv_properties* %10, i32 0, i32 1
store %struct.dtv_property* %8, %struct.dtv_property** %15
store %struct.dtv_property* %8, %struct.dtv_property** %9
%16 = load i8*, i8** %7
%17 = load %struct.dtv_property*, %struct.dtv_property** %9
%18 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %17, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 0
store i8* %16, i8** %19
%20 = load i32, i32* %5
%21 = load i32, i32* @FE_SET_PROPERTY
%22 = call i32 @ioctl(i32 %20, i32 %21, %struct.dtv_properties* %10)
store i32 %22, i32* %11
%23 = load i32, i32* %11
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %3
%26 = load i32, i32* @stderr
%27 = load i32, i32* %11
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %27)
store i32 -1, i32* %4
br label %30
29: ; preds = %3
store i32 0, i32* %4
br label %30
30: ; preds = %29, %25
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
%struct.dtv_property = type { %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.dtv_properties = type { i32, %struct.dtv_property* }
@FE_SET_PROPERTY = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"FE_SET_PROPERTY returned %d\0A\00"
define i32 @set_property(i32 %0, i8* %1, i8* %2) {
%4 = alloca %struct.dtv_property
%5 = alloca %struct.dtv_properties
%6 = bitcast %struct.dtv_property* %4 to i8*
%7 = bitcast %struct.dtv_properties* %5 to i8*
%8 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %4, i64 0, i32 1
store i8* %1, i8** %8
%9 = getelementptr inbounds %struct.dtv_properties, %struct.dtv_properties* %5, i64 0, i32 0
store i32 1, i32* %9
%10 = getelementptr inbounds %struct.dtv_properties, %struct.dtv_properties* %5, i64 0, i32 1
store %struct.dtv_property* %4, %struct.dtv_property** %10
%11 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %4, i64 0, i32 0, i32 0
store i8* %2, i8** %11
%12 = load i32, i32* @FE_SET_PROPERTY
%13 = call i32 @ioctl(i32 %0, i32 %12, %struct.dtv_properties* %5)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %18
18: ; preds = %3, %15
%19 = phi i32 [ -1, %15 ], [ 0, %3 ]
ret i32 %19
}