#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 PATH_MAX;
int /*<<< orphan*/ cache_add(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void cache_scsi(char *name, int major) {
  char tem[PATH_MAX], format[PATH_MAX];
  int i, j, dev;
  int k = strlen("/dev") + 3;
  for (i = 15; i >= 0; i--) {
    dev = ((((i << 4) & 0xff) | ((major & 0xfff) << 8) |
            (((unsigned long long int)((i << 4) & ~0xff)) << 12) |
            (((unsigned long long int)(major & ~0xfff)) << 32)));
    {
      strcpy(format, name);
      format[k] += i;
      cache_add(format, dev);
      strcat(format, "%d");
    }
    for (j = 15; j; j--) {
      sprintf(tem, format, j);
      cache_add(tem, dev | j);
    }
  }
}


x86 assembly (clang, -O0):
<cache_scsi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x48(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
lea    0xe50(%rip),%rdi
call   1040 <strlen@plt>
add    $0x3,%eax
mov    %eax,-0x38(%rbp)
movl   $0xf,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     129d <cache_scsi+0x14d>
mov    -0x40(%rbp),%rdi
mov    -0x2c(%rbp),%eax
shl    $0x4,%eax
and    $0xff,%eax
mov    -0xc(%rbp),%ecx
and    $0xfff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
cltq
mov    -0x2c(%rbp),%ecx
shl    $0x4,%ecx
and    $0xffffff00,%ecx
movslq %ecx,%rcx
shl    $0xc,%rcx
or     %rcx,%rax
mov    -0xc(%rbp),%ecx
and    $0xfffff000,%ecx
movslq %ecx,%rcx
shl    $0x20,%rcx
or     %rcx,%rax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x40(%rbp),%rdi
mov    -0x2c(%rbp),%edx
movslq -0x38(%rbp),%rax
movsbl (%rdi,%rax,1),%ecx
add    %edx,%ecx
mov    %cl,(%rdi,%rax,1)
mov    -0x34(%rbp),%esi
call   1060 <cache_add@plt>
mov    -0x40(%rbp),%rdi
lea    0xdbe(%rip),%rsi
call   1050 <strcat@plt>
movl   $0xf,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     128a <cache_scsi+0x13a>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%edx
call   1070 <sprintf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%esi
or     -0x30(%rbp),%esi
call   1060 <cache_add@plt>
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    1253 <cache_scsi+0x103>
jmp    128f <cache_scsi+0x13f>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c2 <cache_scsi+0x72>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cache_scsi>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %rdi,-0x40(%rbp)
mov    0x2e81(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
lea    0xe6e(%rip),%rdi
call   1040 <strlen@plt>
cltq
mov    %rax,-0x38(%rbp)
shl    $0x8,%r14d
and    $0xfff00,%r14d
mov    %r14d,-0x30(%rbp)
mov    $0xf0000,%r14d
mov    $0xf0,%eax
mov    $0xf,%r15b
nopw   0x0(%rax,%rax,1)
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
and    $0xf0,%eax
or     -0x30(%rbp),%eax
mov    %r14d,%r13d
and    $0xfff00000,%r13d
or     %eax,%r13d
mov    %r12,%rdi
mov    -0x40(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rax
add    %r15b,0x3(%r12,%rax,1)
mov    %r12,%rdi
mov    %r13d,%esi
call   1060 <cache_add@plt>
mov    %r12,%rdi
lea    0xe00(%rip),%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xf,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0xf,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xe,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0xe,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xd,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0xd,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xc,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0xc,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xb,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0xb,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0xa,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x9,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0x9,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0x8,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x7,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0x7,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x6,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0x6,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x5,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0x5,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0x4,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0x3,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1070 <sprintf@plt>
mov    %r13d,%esi
or     $0x2,%esi
mov    %rbx,%rdi
call   1060 <cache_add@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1070 <sprintf@plt>
or     $0x1,%r13d
mov    %rbx,%rdi
mov    %r13d,%esi
call   1060 <cache_add@plt>
mov    -0x2c(%rbp),%eax
add    $0xffff0000,%r14d
add    $0xfffffff0,%eax
add    $0xff,%r15b
cmp    $0xffff0000,%r14d
jne    11c0 <cache_scsi+0x70>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [5 x i8] c"/dev\00"
@.str.1 = [3 x i8] c"%d\00"
define void @cache_scsi(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%12 = load i32, i32* @PATH_MAX
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %5
%15 = alloca i8, i64 %13
store i64 %13, i64* %6
%16 = load i32, i32* @PATH_MAX
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
store i64 %17, i64* %7
%19 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = add nsw i32 %19, 3
store i32 %20, i32* %11
store i32 15, i32* %8
br label %21
21: ; preds = %72, %2
%22 = load i32, i32* %8
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %75
24: ; preds = %21
%25 = load i32, i32* %8
%26 = shl i32 %25, 4
%27 = and i32 %26, 255
%28 = load i32, i32* %4
%29 = and i32 %28, 4095
%30 = shl i32 %29, 8
%31 = or i32 %27, %30
%32 = sext i32 %31 to i64
%33 = load i32, i32* %8
%34 = shl i32 %33, 4
%35 = and i32 %34, -256
%36 = sext i32 %35 to i64
%37 = shl i64 %36, 12
%38 = or i64 %32, %37
%39 = load i32, i32* %4
%40 = and i32 %39, -4096
%41 = sext i32 %40 to i64
%42 = shl i64 %41, 32
%43 = or i64 %38, %42
%44 = trunc i64 %43 to i32
store i32 %44, i32* %10
%45 = load i8*, i8** %3
%46 = call i32 @strcpy(i8* %18, i8* %45)
%47 = load i32, i32* %8
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %18, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = add nsw i32 %52, %47
%54 = trunc i32 %53 to i8
store i8 %54, i8* %50
%55 = load i32, i32* %10
%56 = call i32 @cache_add(i8* %18, i32 %55)
%57 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 15, i32* %9
br label %58
58: ; preds = %68, %24
%59 = load i32, i32* %9
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %58
%62 = load i32, i32* %9
%63 = call i32 @sprintf(i8* %15, i8* %18, i32 %62)
%64 = load i32, i32* %10
%65 = load i32, i32* %9
%66 = or i32 %64, %65
%67 = call i32 @cache_add(i8* %15, i32 %66)
br label %68
68: ; preds = %61
%69 = load i32, i32* %9
%70 = add nsw i32 %69, -1
store i32 %70, i32* %9
br label %58
71: ; preds = %58
br label %72
72: ; preds = %71
%73 = load i32, i32* %8
%74 = add nsw i32 %73, -1
store i32 %74, i32* %8
br label %21
75: ; preds = %21
%76 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [5 x i8] c"/dev\00"
@.str.1 = [3 x i8] c"%d\00"
define void @cache_scsi(i8* %0, i32 %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = alloca i8, i64 %4
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = add nsw i32 %7, 3
%9 = shl i32 %1, 8
%10 = and i32 %9, 1048320
%11 = sext i32 %8 to i64
%12 = getelementptr inbounds i8, i8* %6, i64 %11
br label %13
13: ; preds = %2, %13
%14 = phi i32 [ 15, %2 ], [ %72, %13 ]
%15 = shl i32 %14, 4
%16 = and i32 %15, 240
%17 = or i32 %16, %10
%18 = shl i32 %14, 16
%19 = and i32 %18, -1048576
%20 = or i32 %17, %19
%21 = call i32 @strcpy(i8* %6, i8* %0)
%22 = load i8, i8* %12
%23 = trunc i32 %14 to i8
%24 = add i8 %22, %23
store i8 %24, i8* %12
%25 = call i32 @cache_add(i8* %6, i32 %20)
%26 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @sprintf(i8* %5, i8* %6, i32 15)
%28 = or i32 %20, 15
%29 = call i32 @cache_add(i8* %5, i32 %28)
%30 = call i32 @sprintf(i8* %5, i8* %6, i32 14)
%31 = or i32 %20, 14
%32 = call i32 @cache_add(i8* %5, i32 %31)
%33 = call i32 @sprintf(i8* %5, i8* %6, i32 13)
%34 = or i32 %20, 13
%35 = call i32 @cache_add(i8* %5, i32 %34)
%36 = call i32 @sprintf(i8* %5, i8* %6, i32 12)
%37 = or i32 %20, 12
%38 = call i32 @cache_add(i8* %5, i32 %37)
%39 = call i32 @sprintf(i8* %5, i8* %6, i32 11)
%40 = or i32 %20, 11
%41 = call i32 @cache_add(i8* %5, i32 %40)
%42 = call i32 @sprintf(i8* %5, i8* %6, i32 10)
%43 = or i32 %20, 10
%44 = call i32 @cache_add(i8* %5, i32 %43)
%45 = call i32 @sprintf(i8* %5, i8* %6, i32 9)
%46 = or i32 %20, 9
%47 = call i32 @cache_add(i8* %5, i32 %46)
%48 = call i32 @sprintf(i8* %5, i8* %6, i32 8)
%49 = or i32 %20, 8
%50 = call i32 @cache_add(i8* %5, i32 %49)
%51 = call i32 @sprintf(i8* %5, i8* %6, i32 7)
%52 = or i32 %20, 7
%53 = call i32 @cache_add(i8* %5, i32 %52)
%54 = call i32 @sprintf(i8* %5, i8* %6, i32 6)
%55 = or i32 %20, 6
%56 = call i32 @cache_add(i8* %5, i32 %55)
%57 = call i32 @sprintf(i8* %5, i8* %6, i32 5)
%58 = or i32 %20, 5
%59 = call i32 @cache_add(i8* %5, i32 %58)
%60 = call i32 @sprintf(i8* %5, i8* %6, i32 4)
%61 = or i32 %20, 4
%62 = call i32 @cache_add(i8* %5, i32 %61)
%63 = call i32 @sprintf(i8* %5, i8* %6, i32 3)
%64 = or i32 %20, 3
%65 = call i32 @cache_add(i8* %5, i32 %64)
%66 = call i32 @sprintf(i8* %5, i8* %6, i32 2)
%67 = or i32 %20, 2
%68 = call i32 @cache_add(i8* %5, i32 %67)
%69 = call i32 @sprintf(i8* %5, i8* %6, i32 1)
%70 = or i32 %20, 1
%71 = call i32 @cache_add(i8* %5, i32 %70)
%72 = add nsw i32 %14, -1
%73 = icmp eq i32 %14, 0
br i1 %73, label %74, label %13
74: ; preds = %13
ret void
}