#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 */
char *getenv(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned int, unsigned int,
                            unsigned int, unsigned int, unsigned int,
                            unsigned int, ...);
char *strchr(char *, char);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
int get_usb_modalias(char *modalias, int modalias_len) {
  char *product_env, *type_env, *interface_env;
  char *ptr;
  unsigned int idVendor, idProduct, bcdDevice;
  unsigned int device_class, device_subclass, device_protocol;
  unsigned int interface_class, interface_subclass, interface_protocol;
  product_env = getenv("PRODUCT");
  type_env = getenv("TYPE");
  interface_env = getenv("INTERFACE");
  if (product_env == NULL || type_env == NULL)
    return -1;
  ptr = strchr(product_env, '/');
  if (ptr == NULL || ptr[1] == '\0')
    return -1;
  idVendor = strtoul(product_env, NULL, 16);
  idProduct = strtoul(ptr + 1, NULL, 16);
  ptr = strchr(ptr + 1, '/');
  if (ptr == NULL || ptr[1] == '\0')
    return -1;
  bcdDevice = strtoul(ptr + 1, NULL, 16);
  ptr = strchr(type_env, '/');
  if (ptr == NULL || ptr[1] == '\0')
    return -1;
  device_class = strtoul(type_env, NULL, 10);
  device_subclass = strtoul(ptr + 1, NULL, 10);
  ptr = strchr(ptr + 1, '/');
  if (ptr == NULL || ptr[1] == '\0')
    return -1;
  device_protocol = strtoul(ptr + 1, NULL, 10);
  if (interface_env != NULL) {
    ptr = strchr(interface_env, '/');
    if (ptr == NULL || ptr[1] == '\0')
      return -1;
    interface_class = strtoul(interface_env, NULL, 10);
    interface_subclass = strtoul(ptr + 1, NULL, 10);
    ptr = strchr(ptr + 1, '/');
    if (ptr == NULL || ptr[1] == '\0')
      return -1;
    interface_protocol = strtoul(ptr + 1, NULL, 10);
    snprintf(modalias, modalias_len,
             "MODALIAS=usb:v%04Xp%04Xd%04X"
             "dc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
             idVendor, idProduct, bcdDevice, device_class, device_subclass,
             device_protocol, interface_class, interface_subclass,
             interface_protocol);
  } else {
    snprintf(modalias, modalias_len,
             "MODALIAS=usb:v%04Xp%04Xd%04X"
             "dc%02Xdsc%02Xdp%02Xic*isc*ip*",
             idVendor, idProduct, bcdDevice, device_class, device_subclass,
             device_protocol);
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_usb_modalias>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %rdi,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
lea    0xea2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x38(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x40(%rbp)
lea    0xe8f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     119d <get_usb_modalias+0x5d>
cmpq   $0x0,-0x40(%rbp)
jne    11a9 <get_usb_modalias+0x69>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1486 <get_usb_modalias+0x346>
mov    -0x38(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     11d7 <get_usb_modalias+0x97>
mov    -0x50(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    11e3 <get_usb_modalias+0xa3>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1486 <get_usb_modalias+0x346>
mov    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1243 <get_usb_modalias+0x103>
mov    -0x50(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    124f <get_usb_modalias+0x10f>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1486 <get_usb_modalias+0x346>
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x40(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1296 <get_usb_modalias+0x156>
mov    -0x50(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    12a2 <get_usb_modalias+0x162>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1486 <get_usb_modalias+0x346>
mov    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x60(%rbp)
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x64(%rbp)
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1302 <get_usb_modalias+0x1c2>
mov    -0x50(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    130e <get_usb_modalias+0x1ce>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1486 <get_usb_modalias+0x346>
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x68(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1447 <get_usb_modalias+0x307>
mov    -0x48(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1360 <get_usb_modalias+0x220>
mov    -0x50(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    136c <get_usb_modalias+0x22c>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1486 <get_usb_modalias+0x346>
mov    -0x48(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x70(%rbp)
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     13cc <get_usb_modalias+0x28c>
mov    -0x50(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    13d8 <get_usb_modalias+0x298>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1486 <get_usb_modalias+0x346>
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x74(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x54(%rbp),%ecx
mov    -0x58(%rbp),%r8d
mov    -0x5c(%rbp),%r9d
mov    -0x60(%rbp),%r15d
mov    -0x64(%rbp),%r14d
mov    -0x68(%rbp),%ebx
mov    -0x6c(%rbp),%r11d
mov    -0x70(%rbp),%r10d
mov    -0x74(%rbp),%eax
lea    0xbf7(%rip),%rdx
mov    %r15d,(%rsp)
mov    %r14d,0x8(%rsp)
mov    %ebx,0x10(%rsp)
mov    %r11d,0x18(%rsp)
mov    %r10d,0x20(%rsp)
mov    %eax,0x28(%rsp)
mov    $0x0,%al
call   1050 <snprintf@plt>
jmp    147f <get_usb_modalias+0x33f>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x54(%rbp),%ecx
mov    -0x58(%rbp),%r8d
mov    -0x5c(%rbp),%r9d
mov    -0x60(%rbp),%r11d
mov    -0x64(%rbp),%r10d
mov    -0x68(%rbp),%eax
lea    0xbef(%rip),%rdx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_usb_modalias>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xea5(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbp
lea    0xe9e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r15
lea    0xe94(%rip),%rdi
call   1030 <getenv@plt>
mov    $0xffffffff,%r13d
test   %rbp,%rbp
je     13a7 <get_usb_modalias+0x267>
test   %r15,%r15
je     13a7 <get_usb_modalias+0x267>
mov    %rax,%r12
mov    %rbx,0x10(%rsp)
mov    %r14d,0x4(%rsp)
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     13a7 <get_usb_modalias+0x267>
mov    %rax,%r14
cmpb   $0x0,0x1(%rax)
je     13a7 <get_usb_modalias+0x267>
add    $0x1,%r14
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     13a7 <get_usb_modalias+0x267>
cmpb   $0x0,0x1(%rax)
je     13a7 <get_usb_modalias+0x267>
mov    %ebp,%r14d
add    $0x1,%rax
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,(%rsp)
mov    %r15,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     13a7 <get_usb_modalias+0x267>
mov    %rax,%rbp
cmpb   $0x0,0x1(%rax)
je     13a7 <get_usb_modalias+0x267>
add    $0x1,%rbp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %rax,0x8(%rsp)
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     13a7 <get_usb_modalias+0x267>
cmpb   $0x0,0x1(%rax)
je     13a7 <get_usb_modalias+0x267>
add    $0x1,%rax
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebp
test   %r12,%r12
je     1374 <get_usb_modalias+0x234>
mov    %rbp,0x20(%rsp)
mov    %r12,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     13a7 <get_usb_modalias+0x267>
mov    %rax,%rbp
cmpb   $0x0,0x1(%rax)
je     13a7 <get_usb_modalias+0x267>
mov    %r15,0x18(%rsp)
add    $0x1,%rbp
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     13a7 <get_usb_modalias+0x267>
cmpb   $0x0,0x1(%rax)
je     13a7 <get_usb_modalias+0x267>
add    $0x1,%rax
xor    %r13d,%r13d
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebp
lea    0xcd3(%rip),%rdx
mov    0x10(%rsp),%rdi
mov    0x4(%rsp),%esi
mov    %ebx,%ecx
mov    %r14d,%r8d
mov    (%rsp),%r9d
xor    %eax,%eax
push   %rbp
push   %r12
push   %r15
push   0x38(%rsp)
push   0x28(%rsp)
push   0x40(%rsp)
call   1050 <snprintf@plt>
add    $0x30,%rsp
jmp    13a7 <get_usb_modalias+0x267>
sub    $0x8,%rsp
lea    0xcdb(%rip),%rdx
mov    0x18(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %ebx,%ecx
mov    %r14d,%r8d
mov    0x8(%rsp),%r9d
xor    %eax,%eax
push   %rbp
push   0x18(%rsp)
push   %r15
call   1050 <snprintf@plt>
add    $0x20,%rsp
xor    %r13d,%r13d
mov    %r13d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"PRODUCT\00"
@.str.1 = [5 x i8] c"TYPE\00"
@.str.2 = [10 x i8] c"INTERFACE\00"
@.str.3 = [67 x i8] c"MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\00"
@.str.4 = [58 x i8] c"MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\00"
define i32 @get_usb_modalias(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%19 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %6
%20 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %20, i8** %7
%21 = call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i8* %21, i8** %8
%22 = load i8*, i8** %6
%23 = icmp eq i8* %22, null
br i1 %23, label %27, label %24
24: ; preds = %2
%25 = load i8*, i8** %7
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %28
27: ; preds = %24, %2
store i32 -1, i32* %3
br label %154
28: ; preds = %24
%29 = load i8*, i8** %6
%30 = call i8* @strchr(i8* %29, i8 signext 47)
store i8* %30, i8** %9
%31 = load i8*, i8** %9
%32 = icmp eq i8* %31, null
br i1 %32, label %39, label %33
33: ; preds = %28
%34 = load i8*, i8** %9
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %33, %28
store i32 -1, i32* %3
br label %154
40: ; preds = %33
%41 = load i8*, i8** %6
%42 = call i32 @strtoul(i8* %41, i32* null, i32 16)
store i32 %42, i32* %10
%43 = load i8*, i8** %9
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = call i32 @strtoul(i8* %44, i32* null, i32 16)
store i32 %45, i32* %11
%46 = load i8*, i8** %9
%47 = getelementptr inbounds i8, i8* %46, i64 1
%48 = call i8* @strchr(i8* %47, i8 signext 47)
store i8* %48, i8** %9
%49 = load i8*, i8** %9
%50 = icmp eq i8* %49, null
br i1 %50, label %57, label %51
51: ; preds = %40
%52 = load i8*, i8** %9
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %51, %40
store i32 -1, i32* %3
br label %154
58: ; preds = %51
%59 = load i8*, i8** %9
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = call i32 @strtoul(i8* %60, i32* null, i32 16)
store i32 %61, i32* %12
%62 = load i8*, i8** %7
%63 = call i8* @strchr(i8* %62, i8 signext 47)
store i8* %63, i8** %9
%64 = load i8*, i8** %9
%65 = icmp eq i8* %64, null
br i1 %65, label %72, label %66
66: ; preds = %58
%67 = load i8*, i8** %9
%68 = getelementptr inbounds i8, i8* %67, i64 1
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %66, %58
store i32 -1, i32* %3
br label %154
73: ; preds = %66
%74 = load i8*, i8** %7
%75 = call i32 @strtoul(i8* %74, i32* null, i32 10)
store i32 %75, i32* %13
%76 = load i8*, i8** %9
%77 = getelementptr inbounds i8, i8* %76, i64 1
%78 = call i32 @strtoul(i8* %77, i32* null, i32 10)
store i32 %78, i32* %14
%79 = load i8*, i8** %9
%80 = getelementptr inbounds i8, i8* %79, i64 1
%81 = call i8* @strchr(i8* %80, i8 signext 47)
store i8* %81, i8** %9
%82 = load i8*, i8** %9
%83 = icmp eq i8* %82, null
br i1 %83, label %90, label %84
84: ; preds = %73
%85 = load i8*, i8** %9
%86 = getelementptr inbounds i8, i8* %85, i64 1
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %91
90: ; preds = %84, %73
store i32 -1, i32* %3
br label %154
91: ; preds = %84
%92 = load i8*, i8** %9
%93 = getelementptr inbounds i8, i8* %92, i64 1
%94 = call i32 @strtoul(i8* %93, i32* null, i32 10)
store i32 %94, i32* %15
%95 = load i8*, i8** %8
%96 = icmp ne i8* %95, null
br i1 %96, label %97, label %143
97: ; preds = %91
%98 = load i8*, i8** %8
%99 = call i8* @strchr(i8* %98, i8 signext 47)
store i8* %99, i8** %9
%100 = load i8*, i8** %9
%101 = icmp eq i8* %100, null
br i1 %101, label %108, label %102
102: ; preds = %97
%103 = load i8*, i8** %9
%104 = getelementptr inbounds i8, i8* %103, i64 1
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp eq i32 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %102, %97
store i32 -1, i32* %3
br label %154
109: ; preds = %102
%110 = load i8*, i8** %8
%111 = call i32 @strtoul(i8* %110, i32* null, i32 10)
store i32 %111, i32* %16
%112 = load i8*, i8** %9
%113 = getelementptr inbounds i8, i8* %112, i64 1
%114 = call i32 @strtoul(i8* %113, i32* null, i32 10)
store i32 %114, i32* %17
%115 = load i8*, i8** %9
%116 = getelementptr inbounds i8, i8* %115, i64 1
%117 = call i8* @strchr(i8* %116, i8 signext 47)
store i8* %117, i8** %9
%118 = load i8*, i8** %9
%119 = icmp eq i8* %118, null
br i1 %119, label %126, label %120
120: ; preds = %109
%121 = load i8*, i8** %9
%122 = getelementptr inbounds i8, i8* %121, i64 1
%123 = load i8, i8* %122
%124 = sext i8 %123 to i32
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %127
126: ; preds = %120, %109
store i32 -1, i32* %3
br label %154
127: ; preds = %120
%128 = load i8*, i8** %9
%129 = getelementptr inbounds i8, i8* %128, i64 1
%130 = call i32 @strtoul(i8* %129, i32* null, i32 10)
store i32 %130, i32* %18
%131 = load i8*, i8** %4
%132 = load i32, i32* %5
%133 = load i32, i32* %10
%134 = load i32, i32* %11
%135 = load i32, i32* %12
%136 = load i32, i32* %13
%137 = load i32, i32* %14
%138 = load i32, i32* %15
%139 = load i32, i32* %16
%140 = load i32, i32* %17
%141 = load i32, i32* %18
%142 = call i32 (i8*, i32, i8*, i32, i32, i32, i32, i32, i32, ...) @snprintf(i8* %131, i32 %132, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i32 %133, i32 %134, i32 %135, i32 %136, i32 %137, i32 %138, i32 %139, i32 %140, i32 %141)
br label %153
143: ; preds = %91
%144 = load i8*, i8** %4
%145 = load i32, i32* %5
%146 = load i32, i32* %10
%147 = load i32, i32* %11
%148 = load i32, i32* %12
%149 = load i32, i32* %13
%150 = load i32, i32* %14
%151 = load i32, i32* %15
%152 = call i32 (i8*, i32, i8*, i32, i32, i32, i32, i32, i32, ...) @snprintf(i8* %144, i32 %145, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i32 %146, i32 %147, i32 %148, i32 %149, i32 %150, i32 %151)
br label %153
153: ; preds = %143, %127
store i32 0, i32* %3
br label %154
154: ; preds = %153, %126, %108, %90, %72, %57, %39, %27
%155 = load i32, i32* %3
ret i32 %155
}

LLVM IR (-O2):
@.str = [8 x i8] c"PRODUCT\00"
@.str.1 = [5 x i8] c"TYPE\00"
@.str.2 = [10 x i8] c"INTERFACE\00"
@.str.3 = [67 x i8] c"MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\00"
@.str.4 = [58 x i8] c"MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\00"
define i32 @get_usb_modalias(i8* %0, i32 %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i8* %3, null
%7 = icmp eq i8* %4, null
%8 = or i1 %6, %7
br i1 %8, label %66, label %9
9: ; preds = %2
%10 = tail call i8* @strchr(i8* dereferenceable(1) %3, i8 signext 47)
%11 = icmp eq i8* %10, null
br i1 %11, label %66, label %12
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %66, label %16
16: ; preds = %12
%17 = tail call i32 @strtoul(i8* nocapture %3, i32* null, i32 16)
%18 = tail call i32 @strtoul(i8* nocapture %13, i32* null, i32 16)
%19 = tail call i8* @strchr(i8* %13, i8 signext 47)
%20 = icmp eq i8* %19, null
br i1 %20, label %66, label %21
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %19, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %66, label %25
25: ; preds = %21
%26 = tail call i32 @strtoul(i8* nocapture %22, i32* null, i32 16)
%27 = tail call i8* @strchr(i8* dereferenceable(1) %4, i8 signext 47)
%28 = icmp eq i8* %27, null
br i1 %28, label %66, label %29
29: ; preds = %25
%30 = getelementptr inbounds i8, i8* %27, i64 1
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %66, label %33
33: ; preds = %29
%34 = tail call i32 @strtoul(i8* nocapture %4, i32* null, i32 10)
%35 = tail call i32 @strtoul(i8* nocapture %30, i32* null, i32 10)
%36 = tail call i8* @strchr(i8* %30, i8 signext 47)
%37 = icmp eq i8* %36, null
br i1 %37, label %66, label %38
38: ; preds = %33
%39 = getelementptr inbounds i8, i8* %36, i64 1
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 0
br i1 %41, label %66, label %42
42: ; preds = %38
%43 = tail call i32 @strtoul(i8* nocapture %39, i32* null, i32 10)
%44 = icmp eq i8* %5, null
br i1 %44, label %64, label %45
45: ; preds = %42
%46 = tail call i8* @strchr(i8* %5, i8 signext 47)
%47 = icmp eq i8* %46, null
br i1 %47, label %66, label %48
48: ; preds = %45
%49 = getelementptr inbounds i8, i8* %46, i64 1
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 0
br i1 %51, label %66, label %52
52: ; preds = %48
%53 = tail call i32 @strtoul(i8* nocapture %5, i32* null, i32 10)
%54 = tail call i32 @strtoul(i8* nocapture %49, i32* null, i32 10)
%55 = tail call i8* @strchr(i8* %49, i8 signext 47)
%56 = icmp eq i8* %55, null
br i1 %56, label %66, label %57
57: ; preds = %52
%58 = getelementptr inbounds i8, i8* %55, i64 1
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 0
br i1 %60, label %66, label %61
61: ; preds = %57
%62 = tail call i32 @strtoul(i8* nocapture %58, i32* null, i32 10)
%63 = tail call i32 (i8*, i32, i8*, i32, i32, i32, i32, i32, i32, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %18, i32 %26, i32 %34, i32 %35, i32 %43, i32 %53, i32 %54, i32 %62)
br label %66
64: ; preds = %42
%65 = tail call i32 (i8*, i32, i8*, i32, i32, i32, i32, i32, i32, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i32 %17, i32 %18, i32 %26, i32 %34, i32 %35, i32 %43)
br label %66
66: ; preds = %61, %64, %52, %57, %45, %48, %33, %38, %25, %29, %16, %21, %9, %12, %2
%67 = phi i32 [ -1, %2 ], [ -1, %12 ], [ -1, %9 ], [ -1, %21 ], [ -1, %16 ], [ -1, %29 ], [ -1, %25 ], [ -1, %38 ], [ -1, %33 ], [ -1, %48 ], [ -1, %45 ], [ -1, %57 ], [ -1, %52 ], [ 0, %64 ], [ 0, %61 ]
ret i32 %67
}