#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 /*<<< orphan*/ ifr_flags;
  int /*<<< orphan*/ ifr_name;
};
typedef int /*<<< orphan*/ ifr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ IFF_UP;
int /*<<< orphan*/ IF_NAMESIZE;
int /*<<< orphan*/ SIOCSIFFLAGS;
int /*<<< orphan*/ SOCK_DGRAM;
int close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int if_nametoindex(int /*<<< orphan*/);
int ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ memset(struct ifreq *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char const *,
                           int /*<<< orphan*/);
void BringupInterface(const char *name) {
  int fd;
  struct ifreq ifr;
  if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
    fprintf(stderr, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/"
                    "heads/master/src/main/tools/network-tools.c"
                    ":"
                    "34"
                    ": ");
    perror("fd = socket(AF_INET, SOCK_DGRAM, 0)");
    exit(EXIT_FAILURE);
  };
  memset(&ifr, 0, sizeof(ifr));
  strncpy(ifr.ifr_name, name, IF_NAMESIZE);
  if ((if_nametoindex(ifr.ifr_name)) == -1) {
    fprintf(stderr, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/"
                    "heads/master/src/main/tools/network-tools.c"
                    ":"
                    "40"
                    ": ");
    perror("if_nametoindex(ifr.ifr_name)");
    exit(EXIT_FAILURE);
  };
  ifr.ifr_flags |= IFF_UP;
  if ((ioctl(fd, SIOCSIFFLAGS, &ifr)) == -1) {
    fprintf(stderr, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/"
                    "heads/master/src/main/tools/network-tools.c"
                    ":"
                    "44"
                    ": ");
    perror("ioctl(fd, SIOCSIFFLAGS, &ifr)");
    exit(EXIT_FAILURE);
  };
  if ((close(fd)) == -1) {
    fprintf(stderr, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/"
                    "heads/master/src/main/tools/network-tools.c"
                    ":"
                    "46"
                    ": ");
    perror("close(fd)");
    exit(EXIT_FAILURE);
  };
}


x86 assembly (clang, -O0):
<BringupInterface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    11f0 <BringupInterface+0x60>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xec4(%rip),%rdi
call   1090 <perror@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    0x2dc2(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x14(%rbp),%edi
call   1080 <if_nametoindex@plt>
cmp    $0xffffffff,%eax
jne    1255 <BringupInterface+0xc5>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xf24(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    12b1 <BringupInterface+0x121>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
lea    0xef1(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xf86(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0xc(%rbp),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    12f1 <BringupInterface+0x161>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
lea    0xf70(%rip),%rsi
call   1070 <fprintf@plt>
lea    0x1005(%rip),%rdi
call   1090 <perror@plt>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BringupInterface>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
cmp    $0xffffffff,%eax
je     1221 <BringupInterface+0x91>
mov    %eax,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x4(%rsp),%edi
mov    0x2dff(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rsi
call   1030 <strncpy@plt>
mov    0x4(%rsp),%edi
call   1080 <if_nametoindex@plt>
cmp    $0xffffffff,%eax
je     123f <BringupInterface+0xaf>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
or     %eax,(%rsp)
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     125d <BringupInterface+0xcd>
mov    %ebx,%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
je     127b <BringupInterface+0xeb>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xe64(%rip),%rdi
jmp    1297 <BringupInterface+0x107>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xf0b(%rip),%rdi
jmp    1297 <BringupInterface+0x107>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xf16(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xfab(%rip),%rdi
jmp    1297 <BringupInterface+0x107>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xfb7(%rip),%rsi
call   1070 <fprintf@plt>
lea    0x104c(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.ifreq = type { i32, i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@stderr = global i32 0
@.str = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/heads/master/src/main/tools/network-tools.c:34: \00"
@.str.1 = [36 x i8] c"fd = socket(AF_INET, SOCK_DGRAM, 0)\00"
@EXIT_FAILURE = global i32 0
@IF_NAMESIZE = global i32 0
@.str.2 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/heads/master/src/main/tools/network-tools.c:40: \00"
@.str.3 = [29 x i8] c"if_nametoindex(ifr.ifr_name)\00"
@IFF_UP = global i32 0
@SIOCSIFFLAGS = global i32 0
@.str.4 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/heads/master/src/main/tools/network-tools.c:44: \00"
@.str.5 = [30 x i8] c"ioctl(fd, SIOCSIFFLAGS, &ifr)\00"
@.str.6 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/heads/master/src/main/tools/network-tools.c:46: \00"
@.str.7 = [10 x i8] c"close(fd)\00"
define void @BringupInterface(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.ifreq
store i8* %0, i8** %2
%5 = load i32, i32* @AF_INET
%6 = load i32, i32* @SOCK_DGRAM
%7 = call i32 @socket(i32 %5, i32 %6, i32 0)
store i32 %7, i32* %3
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %1
%16 = call i32 @memset(%struct.ifreq* %4, i32 0, i32 8)
%17 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 1
%18 = load i32, i32* %17
%19 = load i8*, i8** %2
%20 = load i32, i32* @IF_NAMESIZE
%21 = call i32 @strncpy(i32 %18, i8* %19, i32 %20)
%22 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 1
%23 = load i32, i32* %22
%24 = call i32 @if_nametoindex(i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %32
26: ; preds = %15
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %15
%33 = load i32, i32* @IFF_UP
%34 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 0
%35 = load i32, i32* %34
%36 = or i32 %35, %33
store i32 %36, i32* %34
%37 = load i32, i32* %3
%38 = load i32, i32* @SIOCSIFFLAGS
%39 = call i32 @ioctl(i32 %37, i32 %38, %struct.ifreq* %4)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %47
41: ; preds = %32
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.4, i64 0, i64 0))
%44 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %32
%48 = load i32, i32* %3
%49 = call i32 @close(i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %57
51: ; preds = %47
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.6, i64 0, i64 0))
%54 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %47
ret void
}

LLVM IR (-O2):
%struct.ifreq = type { i32, i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@stderr = global i32 0
@.str = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/heads/master/src/main/tools/network-tools.c:34: \00"
@.str.1 = [36 x i8] c"fd = socket(AF_INET, SOCK_DGRAM, 0)\00"
@EXIT_FAILURE = global i32 0
@IF_NAMESIZE = global i32 0
@.str.2 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/heads/master/src/main/tools/network-tools.c:40: \00"
@.str.3 = [29 x i8] c"if_nametoindex(ifr.ifr_name)\00"
@IFF_UP = global i32 0
@SIOCSIFFLAGS = global i32 0
@.str.4 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/heads/master/src/main/tools/network-tools.c:44: \00"
@.str.5 = [30 x i8] c"ioctl(fd, SIOCSIFFLAGS, &ifr)\00"
@.str.6 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BobBuildTool/bob/refs/heads/master/src/main/tools/network-tools.c:46: \00"
@.str.7 = [10 x i8] c"close(fd)\00"
define void @BringupInterface(i8* %0) {
%2 = alloca %struct.ifreq
%3 = bitcast %struct.ifreq* %2 to i8*
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_DGRAM
%6 = tail call i32 @socket(i32 %4, i32 %5, i32 0)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
%15 = call i32 @memset(%struct.ifreq* %2, i32 0, i32 8)
%16 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %2, i64 0, i32 1
%17 = load i32, i32* %16
%18 = load i32, i32* @IF_NAMESIZE
%19 = call i32 @strncpy(i32 %17, i8* %0, i32 %18)
%20 = load i32, i32* %16
%21 = call i32 @if_nametoindex(i32 %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %29
23: ; preds = %14
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %14
%30 = load i32, i32* @IFF_UP
%31 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %2, i64 0, i32 0
%32 = load i32, i32* %31
%33 = or i32 %32, %30
store i32 %33, i32* %31
%34 = load i32, i32* @SIOCSIFFLAGS
%35 = call i32 @ioctl(i32 %6, i32 %34, %struct.ifreq* %2)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %43
37: ; preds = %29
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.4, i64 0, i64 0))
%40 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %29
%44 = call i32 @close(i32 %6)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %52
46: ; preds = %43
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.6, i64 0, i64 0))
%49 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %43
ret void
}