#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 stat {
  int /*<<< orphan*/ st_rdev;
  int /*<<< orphan*/ st_mode;
  int /*<<< orphan*/ st_dev;
};

/* Variables and functions */
scalar_t__ S_ISBLK(int /*<<< orphan*/);
scalar_t__ S_ISCHR(int /*<<< orphan*/);
int /*<<< orphan*/ err_sys(char *, char *);
scalar_t__ lstat(char *, struct stat *);
int major(int /*<<< orphan*/);
int minor(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  struct stat buf;
  while (--argc > 0) {
    printf("%s: ", *++argv);
    if (lstat(*argv, &buf) < 0) {
      err_sys("error on stating %s", *argv);
      continue;
    }
    printf("dev = %d/%d", major(buf.st_dev), minor(buf.st_dev));
    if (S_ISCHR(buf.st_mode) || S_ISBLK(buf.st_mode)) {
      printf(" (%s) rdev = %d/%d",
             (S_ISCHR(buf.st_mode) ? "character" : "block"), major(buf.st_rdev),
             minor(buf.st_rdev));
    }
    printf("\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)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1297 <main+0x127>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <lstat@plt>
cmp    $0x0,%rax
jge    11eb <main+0x7b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe24(%rip),%rdi
call   1030 <err_sys@plt>
jmp    1186 <main+0x16>
mov    -0x18(%rbp),%edi
call   1060 <major@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <minor@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1080 <S_ISCHR@plt>
cmp    $0x0,%rax
jne    1235 <main+0xc5>
mov    -0x1c(%rbp),%edi
call   1090 <S_ISBLK@plt>
cmp    $0x0,%rax
je     1284 <main+0x114>
mov    -0x1c(%rbp),%edi
call   1080 <S_ISCHR@plt>
mov    %rax,%rdx
lea    0xdef(%rip),%rax
lea    0xdde(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%edi
call   1060 <major@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <minor@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1186 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     1293 <main+0x113>
mov    %rsi,%rbx
mov    %edi,%r13d
add    $0x1,%r13d
add    $0x8,%rbx
lea    0x8(%rsp),%r15
jmp    11d1 <main+0x51>
nopl   0x0(%rax)
mov    (%rbx),%rsi
lea    0xe4b(%rip),%rdi
call   1040 <err_sys@plt>
add    $0xffffffff,%r13d
add    $0x8,%rbx
cmp    $0x2,%r13d
jbe    1293 <main+0x113>
mov    (%rbx),%rsi
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1080 <lstat@plt>
test   %rax,%rax
js     11b0 <main+0x30>
mov    0x10(%rsp),%ebp
mov    %ebp,%edi
call   1070 <major@plt>
mov    %eax,%r12d
mov    %ebp,%edi
call   1050 <minor@plt>
lea    0xe12(%rip),%rdi
mov    %r12d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%r12d
mov    %r12d,%edi
call   1090 <S_ISCHR@plt>
test   %rax,%rax
jne    1239 <main+0xb9>
mov    %r12d,%edi
call   10a0 <S_ISBLK@plt>
test   %rax,%rax
je     1284 <main+0x104>
mov    %r12d,%edi
call   1090 <S_ISCHR@plt>
test   %rax,%rax
lea    0xde1(%rip),%rbp
lea    0xde4(%rip),%rax
cmove  %rax,%rbp
mov    0x8(%rsp),%r12d
mov    %r12d,%edi
call   1070 <major@plt>
mov    %eax,%r14d
mov    %r12d,%edi
call   1050 <minor@plt>
lea    0xda4(%rip),%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11bf <main+0x3f>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
@.str = [5 x i8] c"%s: \00"
@.str.1 = [20 x i8] c"error on stating %s\00"
@.str.2 = [12 x i8] c"dev = %d/%d\00"
@.str.3 = [19 x i8] c" (%s) rdev = %d/%d\00"
@.str.4 = [10 x i8] c"character\00"
@.str.5 = [6 x i8] c"block\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %55, %20, %2
%8 = load i32, i32* %4
%9 = add nsw i32 %8, -1
store i32 %9, i32* %4
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %57
11: ; preds = %7
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i32 1
store i8** %13, i8*** %5
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8**, i8*** %5
%17 = load i8*, i8** %16
%18 = call i64 @lstat(i8* %17, %struct.stat* %6)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %11
%21 = load i8**, i8*** %5
%22 = load i8*, i8** %21
%23 = call i32 @err_sys(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %7
24: ; preds = %11
%25 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%26 = load i32, i32* %25
%27 = call i32 @major(i32 %26)
%28 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%29 = load i32, i32* %28
%30 = call i32 @minor(i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %30)
%32 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%33 = load i32, i32* %32
%34 = call i64 @S_ISCHR(i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %24
%37 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%38 = load i32, i32* %37
%39 = call i64 @S_ISBLK(i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %55
41: ; preds = %36, %24
%42 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%43 = load i32, i32* %42
%44 = call i64 @S_ISCHR(i32 %43)
%45 = icmp ne i64 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
%48 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%49 = load i32, i32* %48
%50 = call i32 @major(i32 %49)
%51 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%52 = load i32, i32* %51
%53 = call i32 @minor(i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %47, i32 %50, i32 %53)
br label %55
55: ; preds = %41, %36
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %7
57: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
@.str = [5 x i8] c"%s: \00"
@.str.1 = [20 x i8] c"error on stating %s\00"
@.str.2 = [12 x i8] c"dev = %d/%d\00"
@.str.3 = [19 x i8] c" (%s) rdev = %d/%d\00"
@.str.4 = [10 x i8] c"character\00"
@.str.5 = [6 x i8] c"block\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %46
6: ; preds = %2
%7 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%8 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%9 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
br label %10
10: ; preds = %6, %23
%11 = phi i32 [ %0, %6 ], [ %13, %23 ]
%12 = phi i8** [ %1, %6 ], [ %14, %23 ]
%13 = add nsw i32 %11, -1
%14 = getelementptr inbounds i8*, i8** %12, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %14
%18 = call i64 @lstat(i8* %17, %struct.stat* %3)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %10
%21 = load i8*, i8** %14
%22 = tail call i32 @err_sys(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %44
%24 = icmp ugt i32 %11, 2
br i1 %24, label %10, label %46
25: ; preds = %10
%26 = load i32, i32* %7
%27 = tail call i32 @major(i32 %26)
%28 = tail call i32 @minor(i32 %26)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28)
%30 = load i32, i32* %8
%31 = tail call i64 @S_ISCHR(i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %25
%34 = tail call i64 @S_ISBLK(i32 %30)
%35 = icmp eq i64 %34, 0
br i1 %35, label %44, label %36
36: ; preds = %33, %25
%37 = tail call i64 @S_ISCHR(i32 %30)
%38 = icmp eq i64 %37, 0
%39 = select i1 %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0)
%40 = load i32, i32* %9
%41 = tail call i32 @major(i32 %40)
%42 = tail call i32 @minor(i32 %40)
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %39, i32 %41, i32 %42)
br label %44
44: ; preds = %36, %33
%45 = tail call i32 @putchar(i32 10)
br label %23
46: ; preds = %23, %2
ret i32 0
}