#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 */
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
char *strtok(char *, char *);
int read_device_uevent(char *uevent, char *drv, int *pci_ven, int *pci_dev,
                       int *pci_subven, int *pci_subdev, int *domain, int *bus,
                       int *device, int *fn) {
  char uf_name[64];
  FILE *ufile;
  char line[128];
  char *token = NULL;
  char *tmp;
  int i;
  sprintf(uf_name, "%s/%s", uevent, "device/uevent");
  ufile = fopen(uf_name, "r");
  if (ufile == NULL) {
    fprintf(stderr, "File: %s open failed\n", uf_name);
    return -1;
  }
  while (1) {
    if (fgets(line, sizeof(line), ufile) == NULL)
      return -1;
    if (strstr(line, "DRIVER")) {
      token = strtok(line, "=");
      token = strtok(NULL, "=");
      for (i = 0; i < strlen(token); i++) {
        if (token[i] == '\n' || token[i] == '\r')
          token[i] = '\0';
      }
      strcpy(drv, token);
    }
    if (strstr(line, "PCI_ID")) {
      token = strtok(line, "=");
      token = strtok(NULL, "=");
      *pci_ven = atoi(strtok(token, ":"));
      *pci_dev = atoi(strtok(NULL, ":"));
    }
    if (strstr(line, "PCI_SUBSYS_ID")) {
      token = strtok(line, "=");
      token = strtok(NULL, "=");
      *pci_subven = atoi(strtok(token, ":"));
      *pci_subdev = atoi(strtok(NULL, ":"));
    }
    if (strstr(line, "PCI_SLOT_NAME")) {
      token = strtok(line, "=");
      token = strtok(NULL, "=");
      *domain = atoi(strtok(token, ":"));
      *bus = atoi(strtok(NULL, ":"));
      tmp = strtok(NULL, ":");
      *device = atoi(strtok(tmp, "."));
      *fn = atoi(strtok(NULL, "."));
    }
  }
  fclose(ufile);
  return 0;
}


x86 assembly (clang, -O0):
<read_device_uevent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movq   $0x0,-0x118(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe23(%rip),%rsi
lea    0xe22(%rip),%rcx
call   10a0 <sprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
jne    1233 <read_device_uevent+0xa3>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rdx
lea    0xdf4(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1569 <read_device_uevent+0x3d9>
jmp    1238 <read_device_uevent+0xa8>
lea    -0x110(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    $0x80,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    1266 <read_device_uevent+0xd6>
movl   $0xffffffff,-0x4(%rbp)
jmp    1569 <read_device_uevent+0x3d9>
lea    -0x110(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     1357 <read_device_uevent+0x1c7>
lea    -0x110(%rbp),%rdi
lea    0xda2(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x118(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd8b(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x118(%rbp)
movl   $0x0,-0x124(%rbp)
mov    -0x124(%rbp),%eax
mov    %eax,-0x128(%rbp)
mov    -0x118(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x128(%rbp),%eax
cmp    %ecx,%eax
jge    1347 <read_device_uevent+0x1b7>
mov    -0x118(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     131c <read_device_uevent+0x18c>
mov    -0x118(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    132e <read_device_uevent+0x19e>
mov    -0x118(%rbp),%rax
movslq -0x124(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1333 <read_device_uevent+0x1a3>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    12be <read_device_uevent+0x12e>
mov    -0x18(%rbp),%rdi
mov    -0x118(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xcd0(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     13e8 <read_device_uevent+0x258>
lea    -0x110(%rbp),%rdi
lea    0xcb1(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x118(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xc9a(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
lea    0xc89(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xc69(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x110(%rbp),%rdi
lea    0xc48(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     1479 <read_device_uevent+0x2e9>
lea    -0x110(%rbp),%rdi
lea    0xc20(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x118(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xc09(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
lea    0xbf8(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xbd8(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x110(%rbp),%rdi
lea    0xbc5(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     1564 <read_device_uevent+0x3d4>
lea    -0x110(%rbp),%rdi
lea    0xb8f(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x118(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xb78(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
lea    0xb67(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xb47(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xb27(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rdi
lea    0xb2b(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    0x20(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xb0b(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    1238 <read_device_uevent+0xa8>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_device_uevent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
mov    %r9,0x28(%rsp)
mov    %r8,0x20(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%rdx
lea    0xe3c(%rip),%rsi
lea    0xe3b(%rip),%rcx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <sprintf@plt>
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     143a <read_device_uevent+0x2aa>
mov    %rax,%rbp
lea    0x70(%rsp),%rdi
mov    $0x80,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1454 <read_device_uevent+0x2c4>
lea    0x70(%rsp),%r14
lea    0xe19(%rip),%r15
lea    0xe1b(%rip),%r12
jmp    1249 <read_device_uevent+0xb9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rbp,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1454 <read_device_uevent+0x2c4>
mov    %r14,%rdi
lea    0xdd9(%rip),%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     12cd <read_device_uevent+0x13d>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <strtok@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    12c0 <read_device_uevent+0x130>
xor    %r13d,%r13d
jmp    12a8 <read_device_uevent+0x118>
cs nopw 0x0(%rax,%rax,1)
movb   $0x0,(%rbx,%r13,1)
add    $0x1,%r13
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r13
jge    12c0 <read_device_uevent+0x130>
movzbl (%rbx,%r13,1),%eax
cmp    $0xd,%al
je     1290 <read_device_uevent+0x100>
cmp    $0xa,%al
je     1290 <read_device_uevent+0x100>
jmp    1295 <read_device_uevent+0x105>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
lea    0xd5e(%rip),%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     1329 <read_device_uevent+0x199>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <strtok@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    0x10(%rsp),%rcx
mov    %eax,(%rcx)
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    0x18(%rsp),%rcx
mov    %eax,(%rcx)
mov    %r14,%rdi
lea    0xd0b(%rip),%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     1385 <read_device_uevent+0x1f5>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <strtok@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    0x20(%rsp),%rcx
mov    %eax,(%rcx)
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    0x28(%rsp),%rcx
mov    %eax,(%rcx)
mov    %r14,%rdi
lea    0xcbd(%rip),%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     1230 <read_device_uevent+0xa0>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <strtok@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    0x130(%rsp),%rcx
mov    %eax,(%rcx)
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    0x138(%rsp),%rcx
mov    %eax,(%rcx)
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
lea    0xc5b(%rip),%rbx
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    0x140(%rsp),%rcx
mov    %eax,(%rcx)
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    0x148(%rsp),%rcx
mov    %eax,(%rcx)
jmp    1230 <read_device_uevent+0xa0>
mov    0x2b9f(%rip),%rax
mov    (%rax),%edi
lea    0xbcc(%rip),%rsi
lea    0x30(%rsp),%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [14 x i8] c"device/uevent\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [22 x i8] c"File: %s open failed\0A\00"
@.str.4 = [7 x i8] c"DRIVER\00"
@.str.5 = [2 x i8] c"=\00"
@.str.6 = [7 x i8] c"PCI_ID\00"
@.str.7 = [2 x i8] c":\00"
@.str.8 = [14 x i8] c"PCI_SUBSYS_ID\00"
@.str.9 = [14 x i8] c"PCI_SLOT_NAME\00"
@.str.10 = [2 x i8] c".\00"
define i32 @read_device_uevent(i8* %0, i8* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9) {
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca [64 x i8]
%23 = alloca i32*
%24 = alloca [128 x i8]
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i32
store i8* %0, i8** %12
store i8* %1, i8** %13
store i32* %2, i32** %14
store i32* %3, i32** %15
store i32* %4, i32** %16
store i32* %5, i32** %17
store i32* %6, i32** %18
store i32* %7, i32** %19
store i32* %8, i32** %20
store i32* %9, i32** %21
store i8* null, i8** %25
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %22, i64 0, i64 0
%29 = load i8*, i8** %12
%30 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %29, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %22, i64 0, i64 0
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %32, i32** %23
%33 = load i32*, i32** %23
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %39
35: ; preds = %10
%36 = load i32, i32* @stderr
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %22, i64 0, i64 0
%38 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %37)
store i32 -1, i32* %11
br label %142
39: ; preds = %10
br label %40
40: ; preds = %39, %141
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%42 = load i32*, i32** %23
%43 = call i32* @fgets(i8* %41, i32 128, i32* %42)
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %46
45: ; preds = %40
store i32 -1, i32* %11
br label %142
46: ; preds = %40
%47 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%48 = call i64 @strstr(i8* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %88
50: ; preds = %46
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%52 = call i8* @strtok(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %52, i8** %25
%53 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %53, i8** %25
store i32 0, i32* %27
br label %54
54: ; preds = %81, %50
%55 = load i32, i32* %27
%56 = load i8*, i8** %25
%57 = call i32 @strlen(i8* %56)
%58 = icmp slt i32 %55, %57
br i1 %58, label %59, label %84
59: ; preds = %54
%60 = load i8*, i8** %25
%61 = load i32, i32* %27
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 10
br i1 %66, label %75, label %67
67: ; preds = %59
%68 = load i8*, i8** %25
%69 = load i32, i32* %27
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 13
br i1 %74, label %75, label %80
75: ; preds = %67, %59
%76 = load i8*, i8** %25
%77 = load i32, i32* %27
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
store i8 0, i8* %79
br label %80
80: ; preds = %75, %67
br label %81
81: ; preds = %80
%82 = load i32, i32* %27
%83 = add nsw i32 %82, 1
store i32 %83, i32* %27
br label %54
84: ; preds = %54
%85 = load i8*, i8** %13
%86 = load i8*, i8** %25
%87 = call i32 @strcpy(i8* %85, i8* %86)
br label %88
88: ; preds = %84, %46
%89 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%90 = call i64 @strstr(i8* %89, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %103
92: ; preds = %88
%93 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%94 = call i8* @strtok(i8* %93, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %94, i8** %25
%95 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %95, i8** %25
%96 = load i8*, i8** %25
%97 = call i8* @strtok(i8* %96, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%98 = call i32 @atoi(i8* %97)
%99 = load i32*, i32** %14
store i32 %98, i32* %99
%100 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%101 = call i32 @atoi(i8* %100)
%102 = load i32*, i32** %15
store i32 %101, i32* %102
br label %103
103: ; preds = %92, %88
%104 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%105 = call i64 @strstr(i8* %104, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %118
107: ; preds = %103
%108 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%109 = call i8* @strtok(i8* %108, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %109, i8** %25
%110 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %110, i8** %25
%111 = load i8*, i8** %25
%112 = call i8* @strtok(i8* %111, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%113 = call i32 @atoi(i8* %112)
%114 = load i32*, i32** %16
store i32 %113, i32* %114
%115 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%116 = call i32 @atoi(i8* %115)
%117 = load i32*, i32** %17
store i32 %116, i32* %117
br label %118
118: ; preds = %107, %103
%119 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%120 = call i64 @strstr(i8* %119, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%121 = icmp ne i64 %120, 0
br i1 %121, label %122, label %141
122: ; preds = %118
%123 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%124 = call i8* @strtok(i8* %123, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %124, i8** %25
%125 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %125, i8** %25
%126 = load i8*, i8** %25
%127 = call i8* @strtok(i8* %126, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%128 = call i32 @atoi(i8* %127)
%129 = load i32*, i32** %18
store i32 %128, i32* %129
%130 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%131 = call i32 @atoi(i8* %130)
%132 = load i32*, i32** %19
store i32 %131, i32* %132
%133 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %133, i8** %26
%134 = load i8*, i8** %26
%135 = call i8* @strtok(i8* %134, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%136 = call i32 @atoi(i8* %135)
%137 = load i32*, i32** %20
store i32 %136, i32* %137
%138 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%139 = call i32 @atoi(i8* %138)
%140 = load i32*, i32** %21
store i32 %139, i32* %140
br label %141
141: ; preds = %122, %118
br label %40
142: ; preds = %45, %35
%143 = load i32, i32* %11
ret i32 %143
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [14 x i8] c"device/uevent\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [22 x i8] c"File: %s open failed\0A\00"
@.str.4 = [7 x i8] c"DRIVER\00"
@.str.5 = [2 x i8] c"=\00"
@.str.6 = [7 x i8] c"PCI_ID\00"
@.str.7 = [2 x i8] c":\00"
@.str.8 = [14 x i8] c"PCI_SUBSYS_ID\00"
@.str.9 = [14 x i8] c"PCI_SLOT_NAME\00"
@.str.10 = [2 x i8] c".\00"
define i32 @read_device_uevent(i8* %0, i8* %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6, i32* nocapture writeonly %7, i32* nocapture writeonly %8, i32* nocapture writeonly %9) {
%11 = alloca [64 x i8]
%12 = alloca [128 x i8]
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%15 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %10
%19 = call i32* @fgets(i8* %14, i32 128, i32* %16)
%20 = icmp eq i32* %19, null
br i1 %20, label %82, label %24
21: ; preds = %10
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %13)
br label %82
24: ; preds = %18, %79
%25 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %44, label %27
27: ; preds = %24
%28 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%29 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 @strlen(i8* %29)
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %42
32: ; preds = %27, %37
%33 = phi i64 [ %38, %37 ], [ 0, %27 ]
%34 = getelementptr inbounds i8, i8* %29, i64 %33
%35 = load i8, i8* %34
switch i8 %35, label %37 [
i8 10, label %36
i8 13, label %36
]
36: ; preds = %32, %32
store i8 0, i8* %34
br label %37
37: ; preds = %32, %36
%38 = add nuw nsw i64 %33, 1
%39 = call i32 @strlen(i8* %29)
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %38, %40
br i1 %41, label %32, label %42
42: ; preds = %37, %27
%43 = call i32 @strcpy(i8* %1, i8* %29)
br label %44
44: ; preds = %42, %24
%45 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %54, label %47
47: ; preds = %44
%48 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%49 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%50 = call i8* @strtok(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %2
%52 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%53 = call i32 @atoi(i8* %52)
store i32 %53, i32* %3
br label %54
54: ; preds = %47, %44
%55 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %64, label %57
57: ; preds = %54
%58 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%59 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%60 = call i8* @strtok(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%61 = call i32 @atoi(i8* %60)
store i32 %61, i32* %4
%62 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%63 = call i32 @atoi(i8* %62)
store i32 %63, i32* %5
br label %64
64: ; preds = %57, %54
%65 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %79, label %67
67: ; preds = %64
%68 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%69 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%70 = call i8* @strtok(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%71 = call i32 @atoi(i8* %70)
store i32 %71, i32* %6
%72 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%73 = call i32 @atoi(i8* %72)
store i32 %73, i32* %7
%74 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%75 = call i8* @strtok(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%76 = call i32 @atoi(i8* %75)
store i32 %76, i32* %8
%77 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%78 = call i32 @atoi(i8* %77)
store i32 %78, i32* %9
br label %79
79: ; preds = %67, %64
%80 = call i32* @fgets(i8* %14, i32 128, i32* %16)
%81 = icmp eq i32* %80, null
br i1 %81, label %82, label %24
82: ; preds = %79, %18, %21
ret i32 -1
}