#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 */
struct cramfs_inode {
  int mode;
  int size;
  int uid;
  int gid;
};

/* Variables and functions */
int S_IFMT;
scalar_t__ S_ISBLK(int);
scalar_t__ S_ISCHR(int);
int major(int);
int minor(int);
int /*<<< orphan*/ printf(char *, char, int, char *, int, int, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
void print_node(char type, struct cramfs_inode *i, char *name) {
  char info[10];
  if (S_ISCHR(i->mode) || (S_ISBLK(i->mode))) {
    snprintf(info, 10, "%4d,%4d", major(i->size), minor(i->size));
  } else {
    snprintf(info, 10, "%9d", i->size);
  }
  printf("%c %04o %s %5d:%-3d %s\n", type, i->mode & ~S_IFMT, info, i->uid,
         i->gid, name);
}


x86 assembly (clang, -O0):
<print_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1070 <S_ISCHR@plt>
cmp    $0x0,%rax
jne    11a0 <print_node+0x40>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1080 <S_ISBLK@plt>
cmp    $0x0,%rax
je     11e5 <print_node+0x85>
lea    -0x22(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1060 <major@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <minor@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%ecx
mov    %eax,%r8d
mov    $0xa,%esi
lea    0xe27(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
jmp    1203 <print_node+0xa3>
lea    -0x22(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    $0xa,%esi
lea    0xe0c(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x1(%rbp),%sil
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%edx
lea    -0x22(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x18(%rbp),%rax
lea    0xdd2(%rip),%rdi
movsbl %sil,%esi
mov    %rax,(%rsp)
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_node>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%r15d
mov    (%rsi),%edi
call   1070 <S_ISCHR@plt>
test   %rax,%rax
jne    118b <print_node+0x2b>
mov    (%rbx),%edi
call   1080 <S_ISBLK@plt>
test   %rax,%rax
je     11f3 <print_node+0x93>
mov    0x4(%rbx),%edi
call   1060 <major@plt>
mov    %eax,%ebp
mov    0x4(%rbx),%edi
call   1030 <minor@plt>
lea    0xe5c(%rip),%rdx
lea    0xe(%rsp),%rdi
mov    $0xa,%esi
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
not    %edx
and    (%rbx),%edx
mov    0x8(%rbx),%r8d
mov    0xc(%rbx),%r9d
mov    %r14,(%rsp)
movsbl %r15b,%esi
lea    0xe2e(%rip),%rdi
lea    0xe(%rsp),%rcx
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x4(%rbx),%ecx
lea    0xe0b(%rip),%rdx
lea    0xe(%rsp),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    11ba <print_node+0x5a>

LLVM IR (-O0):
%struct.cramfs_inode = type { i32, i32, i32, i32 }
@.str = [8 x i8] c"%4d,%4d\00"
@.str.1 = [4 x i8] c"%9d\00"
@.str.2 = [24 x i8] c"%c %04o %s %5d:%-3d %s\0A\00"
@S_IFMT = global i32 0
define void @print_node(i8 signext %0, %struct.cramfs_inode* %1, i8* %2) {
%4 = alloca i8
%5 = alloca %struct.cramfs_inode*
%6 = alloca i8*
%7 = alloca [10 x i8]
store i8 %0, i8* %4
store %struct.cramfs_inode* %1, %struct.cramfs_inode** %5
store i8* %2, i8** %6
%8 = load %struct.cramfs_inode*, %struct.cramfs_inode** %5
%9 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = call i64 @S_ISCHR(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %3
%14 = load %struct.cramfs_inode*, %struct.cramfs_inode** %5
%15 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i64 @S_ISBLK(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %13, %3
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%21 = load %struct.cramfs_inode*, %struct.cramfs_inode** %5
%22 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %21, i32 0, i32 1
%23 = load i32, i32* %22
%24 = call i32 @major(i32 %23)
%25 = load %struct.cramfs_inode*, %struct.cramfs_inode** %5
%26 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = call i32 @minor(i32 %27)
%29 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %20, i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %28)
br label %36
30: ; preds = %13
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%32 = load %struct.cramfs_inode*, %struct.cramfs_inode** %5
%33 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %32, i32 0, i32 1
%34 = load i32, i32* %33
%35 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %31, i32 10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30, %19
%37 = load i8, i8* %4
%38 = load %struct.cramfs_inode*, %struct.cramfs_inode** %5
%39 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %38, i32 0, i32 0
%40 = load i32, i32* %39
%41 = load i32, i32* @S_IFMT
%42 = xor i32 %41, -1
%43 = and i32 %40, %42
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%45 = load %struct.cramfs_inode*, %struct.cramfs_inode** %5
%46 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %45, i32 0, i32 2
%47 = load i32, i32* %46
%48 = load %struct.cramfs_inode*, %struct.cramfs_inode** %5
%49 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %48, i32 0, i32 3
%50 = load i32, i32* %49
%51 = load i8*, i8** %6
%52 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8 signext %37, i32 %43, i8* %44, i32 %47, i32 %50, i8* %51)
ret void
}

LLVM IR (-O2):
%struct.cramfs_inode = type { i32, i32, i32, i32 }
@.str = [8 x i8] c"%4d,%4d\00"
@.str.1 = [4 x i8] c"%9d\00"
@.str.2 = [24 x i8] c"%c %04o %s %5d:%-3d %s\0A\00"
@S_IFMT = global i32 0
define void @print_node(i8 signext %0, %struct.cramfs_inode* nocapture %1, i8* %2) {
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = tail call i64 @S_ISCHR(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32, i32* %6
%12 = tail call i64 @S_ISBLK(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %10, %3
%15 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %1, i64 0, i32 1
%16 = load i32, i32* %15
%17 = tail call i32 @major(i32 %16)
%18 = load i32, i32* %15
%19 = tail call i32 @minor(i32 %18)
%20 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %5, i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %19)
br label %25
21: ; preds = %10
%22 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %1, i64 0, i32 1
%23 = load i32, i32* %22
%24 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %5, i32 10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %21, %14
%26 = load i32, i32* %6
%27 = load i32, i32* @S_IFMT
%28 = xor i32 %27, -1
%29 = and i32 %26, %28
%30 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %1, i64 0, i32 2
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.cramfs_inode, %struct.cramfs_inode* %1, i64 0, i32 3
%33 = load i32, i32* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8 signext %0, i32 %29, i8* %5, i32 %31, i32 %33, i8* %2)
ret void
}