#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_ieee1394_modalias(char *, int);
int get_input_modalias(char *, int);
int get_pci_modalias(char *, int);
int get_serio_modalias(char *, int);
int get_usb_modalias(char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcmp(char *, char *);
int get_modalias(char *bus, char *modalias, int modalias_len) {
  memset(modalias, 0, modalias_len);
  if (!strcmp(bus, "pci"))
    return get_pci_modalias(modalias, modalias_len);
  if (!strcmp(bus, "usb"))
    return get_usb_modalias(modalias, modalias_len);
  if (!strcmp(bus, "ieee1394"))
    return get_ieee1394_modalias(modalias, modalias_len);
  if (!strcmp(bus, "serio"))
    return get_serio_modalias(modalias, modalias_len);
  if (!strcmp(bus, "input"))
    return get_input_modalias(modalias, modalias_len);
  return -1;
}


x86 assembly (clang, -O0):
<get_modalias>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11be <get_modalias+0x4e>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <get_pci_modalias@plt>
mov    %eax,-0x4(%rbp)
jmp    1279 <get_modalias+0x109>
mov    -0x10(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11eb <get_modalias+0x7b>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <get_usb_modalias@plt>
mov    %eax,-0x4(%rbp)
jmp    1279 <get_modalias+0x109>
mov    -0x10(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1218 <get_modalias+0xa8>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1090 <get_ieee1394_modalias@plt>
mov    %eax,-0x4(%rbp)
jmp    1279 <get_modalias+0x109>
mov    -0x10(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1245 <get_modalias+0xd5>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1080 <get_serio_modalias@plt>
mov    %eax,-0x4(%rbp)
jmp    1279 <get_modalias+0x109>
mov    -0x10(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1272 <get_modalias+0x102>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <get_input_modalias@plt>
mov    %eax,-0x4(%rbp)
jmp    1279 <get_modalias+0x109>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_modalias>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rsi,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe72(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11f0 <get_modalias+0x80>
lea    0xe63(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11ff <get_modalias+0x8f>
lea    0xe54(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     120e <get_modalias+0x9e>
lea    0xe4a(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     121d <get_modalias+0xad>
lea    0xe3d(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     122c <get_modalias+0xbc>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <get_pci_modalias@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <get_usb_modalias@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <get_ieee1394_modalias@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <get_serio_modalias@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <get_input_modalias@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"pci\00"
@.str.1 = [4 x i8] c"usb\00"
@.str.2 = [9 x i8] c"ieee1394\00"
@.str.3 = [6 x i8] c"serio\00"
@.str.4 = [6 x i8] c"input\00"
define i32 @get_modalias(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %6
%9 = load i32, i32* %7
%10 = call i32 @memset(i8* %8, i32 0, i32 %9)
%11 = load i8*, i8** %5
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = load i32, i32* %7
%17 = call i32 @get_pci_modalias(i8* %15, i32 %16)
store i32 %17, i32* %4
br label %51
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = call i32 @get_usb_modalias(i8* %23, i32 %24)
store i32 %25, i32* %4
br label %51
26: ; preds = %18
%27 = load i8*, i8** %5
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i8*, i8** %6
%32 = load i32, i32* %7
%33 = call i32 @get_ieee1394_modalias(i8* %31, i32 %32)
store i32 %33, i32* %4
br label %51
34: ; preds = %26
%35 = load i8*, i8** %5
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8*, i8** %6
%40 = load i32, i32* %7
%41 = call i32 @get_serio_modalias(i8* %39, i32 %40)
store i32 %41, i32* %4
br label %51
42: ; preds = %34
%43 = load i8*, i8** %5
%44 = call i32 @strcmp(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %42
%47 = load i8*, i8** %6
%48 = load i32, i32* %7
%49 = call i32 @get_input_modalias(i8* %47, i32 %48)
store i32 %49, i32* %4
br label %51
50: ; preds = %42
store i32 -1, i32* %4
br label %51
51: ; preds = %50, %46, %38, %30, %22, %14
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@.str = [4 x i8] c"pci\00"
@.str.1 = [4 x i8] c"usb\00"
@.str.2 = [9 x i8] c"ieee1394\00"
@.str.3 = [6 x i8] c"serio\00"
@.str.4 = [6 x i8] c"input\00"
define i32 @get_modalias(i8* nocapture %0, i8* %1, i32 %2) {
%4 = tail call i32 @memset(i8* %1, i32 0, i32 %2)
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @get_pci_modalias(i8* %1, i32 %2)
br label %29
9: ; preds = %3
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @get_usb_modalias(i8* %1, i32 %2)
br label %29
14: ; preds = %9
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @get_ieee1394_modalias(i8* %1, i32 %2)
br label %29
19: ; preds = %14
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @get_serio_modalias(i8* %1, i32 %2)
br label %29
24: ; preds = %19
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = tail call i32 @get_input_modalias(i8* %1, i32 %2)
br label %29
29: ; preds = %24, %27, %22, %17, %12, %7
%30 = phi i32 [ %28, %27 ], [ %23, %22 ], [ %18, %17 ], [ %13, %12 ], [ %8, %7 ], [ -1, %24 ]
ret i32 %30
}