#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 */

/* Variables and functions */
int get_val_from_file(char *);
int snprintf(char *, int, char *, char *);
void find_interface_ids(char *interface_name, int *vendor, int *device,
                        int *sub_vend, int *sub_dev) {
  int ret;
  char sysfile[128];
  ret =
      snprintf(sysfile, 128, "/sys/class/net/%s/device/vendor", interface_name);
  *vendor = get_val_from_file(sysfile);
  ret =
      snprintf(sysfile, 128, "/sys/class/net/%s/device/device", interface_name);
  *device = get_val_from_file(sysfile);
  ret = snprintf(sysfile, 128, "/sys/class/net/%s/device/subsystem_vendor",
                 interface_name);
  *sub_vend = get_val_from_file(sysfile);
  ret = snprintf(sysfile, 128, "/sys/class/net/%s/device/subsystem_device",
                 interface_name);
  *sub_dev = get_val_from_file(sysfile);
}


x86 assembly (clang, -O0):
<find_interface_ids>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x80,%esi
lea    0xeaa(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x2c(%rbp)
lea    -0xb0(%rbp),%rdi
call   1040 <get_val_from_file@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x80,%esi
lea    0xe97(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x2c(%rbp)
lea    -0xb0(%rbp),%rdi
call   1040 <get_val_from_file@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x80,%esi
lea    0xe84(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x2c(%rbp)
lea    -0xb0(%rbp),%rdi
call   1040 <get_val_from_file@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x80,%esi
lea    0xe7b(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x2c(%rbp)
lea    -0xb0(%rbp),%rdi
call   1040 <get_val_from_file@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_interface_ids>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xeb9(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
mov    %r15,%rdi
call   1040 <get_val_from_file@plt>
mov    %eax,0x0(%rbp)
lea    0xeb4(%rip),%rdx
mov    %r15,%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
mov    %r15,%rdi
call   1040 <get_val_from_file@plt>
mov    %eax,0x0(%r13)
lea    0xeb1(%rip),%rdx
mov    %r15,%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
mov    %r15,%rdi
call   1040 <get_val_from_file@plt>
mov    %eax,(%r12)
lea    0xeb8(%rip),%rdx
mov    %r15,%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
mov    %r15,%rdi
call   1040 <get_val_from_file@plt>
mov    %eax,(%r14)
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"/sys/class/net/%s/device/vendor\00"
@.str.1 = [32 x i8] c"/sys/class/net/%s/device/device\00"
@.str.2 = [42 x i8] c"/sys/class/net/%s/device/subsystem_vendor\00"
@.str.3 = [42 x i8] c"/sys/class/net/%s/device/subsystem_device\00"
define void @find_interface_ids(i8* %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca [128 x i8]
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%14 = load i8*, i8** %6
%15 = call i32 @snprintf(i8* %13, i32 128, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 %15, i32* %11
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%17 = call i32 @get_val_from_file(i8* %16)
%18 = load i32*, i32** %7
store i32 %17, i32* %18
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%20 = load i8*, i8** %6
%21 = call i32 @snprintf(i8* %19, i32 128, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 %21, i32* %11
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%23 = call i32 @get_val_from_file(i8* %22)
%24 = load i32*, i32** %8
store i32 %23, i32* %24
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%26 = load i8*, i8** %6
%27 = call i32 @snprintf(i8* %25, i32 128, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 %27, i32* %11
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%29 = call i32 @get_val_from_file(i8* %28)
%30 = load i32*, i32** %9
store i32 %29, i32* %30
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%32 = load i8*, i8** %6
%33 = call i32 @snprintf(i8* %31, i32 128, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %32)
store i32 %33, i32* %11
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%35 = call i32 @get_val_from_file(i8* %34)
%36 = load i32*, i32** %10
store i32 %35, i32* %36
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"/sys/class/net/%s/device/vendor\00"
@.str.1 = [32 x i8] c"/sys/class/net/%s/device/device\00"
@.str.2 = [42 x i8] c"/sys/class/net/%s/device/subsystem_vendor\00"
@.str.3 = [42 x i8] c"/sys/class/net/%s/device/subsystem_device\00"
define void @find_interface_ids(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = alloca [128 x i8]
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 128, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32 @get_val_from_file(i8* %7)
store i32 %9, i32* %1
%10 = call i32 @snprintf(i8* %7, i32 128, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = call i32 @get_val_from_file(i8* %7)
store i32 %11, i32* %2
%12 = call i32 @snprintf(i8* %7, i32 128, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%13 = call i32 @get_val_from_file(i8* %7)
store i32 %13, i32* %3
%14 = call i32 @snprintf(i8* %7, i32 128, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%15 = call i32 @get_val_from_file(i8* %7)
store i32 %15, i32* %4
ret void
}