#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 major(unsigned int);
unsigned int minor(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  unsigned foo = 0xffffffff;
  unsigned min = minor(foo);
  unsigned shift;
  unsigned mask;
  for (mask = ~min, shift = 0; (mask & 1) == 0; shift++, mask >>= 1)
    ;
  printf("sub dev_major { local($dev) = @_; ($dev >> %d) & 0x%x; };\n\n", shift,
         major(foo));
  printf("sub dev_minor { local($dev) = @_; ($dev & 0x%x); };\n\n", min);
  printf("1;\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <minor@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1193 <main+0x63>
jmp    117c <main+0x4c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1168 <main+0x38>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <major@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%edi
call   1040 <minor@plt>
mov    %eax,%ebx
not    %eax
xor    %ebp,%ebp
test   $0x1,%al
jne    116b <main+0x2b>
xor    %ebp,%ebp
mov    %eax,%ecx
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
shr    %ecx
test   $0x2,%al
mov    %ecx,%eax
je     1160 <main+0x20>
mov    $0xffffffff,%edi
call   1060 <major@plt>
lea    0xe84(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeae(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [60 x i8] c"sub dev_major { local($dev) = @_; ($dev >> %d) & 0x%x; };\0A\0A\00"
@.str.1 = [54 x i8] c"sub dev_minor { local($dev) = @_; ($dev & 0x%x); };\0A\0A\00"
@.str.2 = [4 x i8] c"1;\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%10 = load i32, i32* %6
%11 = call i32 @minor(i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = xor i32 %12, -1
store i32 %13, i32* %9
store i32 0, i32* %8
br label %14
14: ; preds = %19, %2
%15 = load i32, i32* %9
%16 = and i32 %15, 1
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14
br label %19
19: ; preds = %18
%20 = load i32, i32* %8
%21 = add i32 %20, 1
store i32 %21, i32* %8
%22 = load i32, i32* %9
%23 = lshr i32 %22, 1
store i32 %23, i32* %9
br label %14
24: ; preds = %14
%25 = load i32, i32* %8
%26 = load i32, i32* %6
%27 = call i32 @major(i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %27)
%29 = load i32, i32* %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [60 x i8] c"sub dev_major { local($dev) = @_; ($dev >> %d) & 0x%x; };\0A\0A\00"
@.str.1 = [54 x i8] c"sub dev_minor { local($dev) = @_; ($dev & 0x%x); };\0A\0A\00"
@str = [3 x i8] c"1;\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @minor(i32 -1)
%4 = xor i32 %3, -1
%5 = and i32 %4, 1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %2, %7
%8 = phi i32 [ %11, %7 ], [ %4, %2 ]
%9 = phi i32 [ %10, %7 ], [ 0, %2 ]
%10 = add i32 %9, 1
%11 = lshr i32 %8, 1
%12 = and i32 %8, 2
%13 = icmp eq i32 %12, 0
br i1 %13, label %7, label %14
14: ; preds = %7, %2
%15 = phi i32 [ 0, %2 ], [ %10, %7 ]
%16 = tail call i32 @major(i32 -1)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i32 0
}