#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 ifreq {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
scalar_t__ ioctl(int, int, struct ifreq *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
void reset_dev_stat(void) {
  int skfd;
  struct ifreq ifr;
  if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    perror("socket error");
  } else {
    if (ioctl(skfd, 0x89b7, &ifr) < 0) {
      printf("ioctl SIOCRESETSTAT error\n");
    }
    close(skfd);
  }
}


x86 assembly (clang, -O0):
<reset_dev_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jge    118e <reset_dev_stat+0x3e>
lea    0xe7c(%rip),%rdi
call   1060 <perror@plt>
jmp    11bd <reset_dev_stat+0x6d>
mov    -0x4(%rbp),%edi
mov    $0x89b7,%esi
lea    -0x8(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
jge    11b5 <reset_dev_stat+0x65>
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1050 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset_dev_stat>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
test   %eax,%eax
js     11a3 <reset_dev_stat+0x53>
mov    %eax,%ebx
lea    0x8(%rsp),%rdx
mov    %eax,%edi
mov    $0x89b7,%esi
call   1040 <ioctl@plt>
test   %rax,%rax
jns    1196 <reset_dev_stat+0x46>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1050 <close@plt>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe56(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1060 <perror@plt>

LLVM IR (-O0):
%struct.ifreq = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [13 x i8] c"socket error\00"
@.str.1 = [27 x i8] c"ioctl SIOCRESETSTAT error\0A\00"
define void @reset_dev_stat() {
%1 = alloca i32
%2 = alloca %struct.ifreq
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_DGRAM
%5 = call i32 @socket(i32 %3, i32 %4, i32 0)
store i32 %5, i32* %1
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %18
9: ; preds = %0
%10 = load i32, i32* %1
%11 = call i64 @ioctl(i32 %10, i32 35255, %struct.ifreq* %2)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
%16 = load i32, i32* %1
%17 = call i32 @close(i32 %16)
br label %18
18: ; preds = %15, %7
ret void
}

LLVM IR (-O2):
%struct.ifreq = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [13 x i8] c"socket error\00"
@str = [26 x i8] c"ioctl SIOCRESETSTAT error\00"
define void @reset_dev_stat() {
%1 = alloca %struct.ifreq
%2 = bitcast %struct.ifreq* %1 to i8*
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_DGRAM
%5 = tail call i32 @socket(i32 %3, i32 %4, i32 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %16
9: ; preds = %0
%10 = call i64 @ioctl(i32 %5, i32 35255, %struct.ifreq* %1)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = call i32 @close(i32 %5)
br label %16
16: ; preds = %14, %7
ret void
}