#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 major(int /*<<< orphan*/);
int minor(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ stat(char const *, struct stat *);
int main(int argc, const char *argv[]) {
  int i;
  struct stat buf;
  for (i = 1; i < argc; i++) {
    printf("%s: ", argv[i]);
    if (stat(argv[i], &buf) < 0) {
      printf("stat error\n");
      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)) ? "characher" : "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)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    128a <main+0x12a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jge    11d5 <main+0x75>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127c <main+0x11c>
mov    -0x18(%rbp),%edi
call   1050 <major@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <minor@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1070 <S_ISCHR@plt>
cmp    $0x0,%rax
jne    121f <main+0xbf>
mov    -0x1c(%rbp),%edi
call   1080 <S_ISBLK@plt>
cmp    $0x0,%rax
je     126e <main+0x10e>
mov    -0x1c(%rbp),%edi
call   1070 <S_ISCHR@plt>
mov    %rax,%rdx
lea    0xdfd(%rip),%rax
lea    0xdec(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <major@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <minor@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <main+0x1d>
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     128a <main+0x10a>
mov    %rsi,%r13
mov    %edi,%r14d
mov    $0x1,%r15d
jmp    11c9 <main+0x49>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe71(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     128a <main+0x10a>
mov    0x0(%r13,%r15,8),%rsi
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13,%r15,8),%rdi
lea    0x8(%rsp),%rsi
call   1080 <stat@plt>
test   %rax,%rax
js     11b0 <main+0x30>
mov    0x10(%rsp),%edi
call   1070 <major@plt>
mov    %eax,%r12d
mov    0x10(%rsp),%edi
call   1050 <minor@plt>
lea    0xe00(%rip),%rdi
mov    %r12d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%edi
call   1090 <S_ISCHR@plt>
test   %rax,%rax
jne    1234 <main+0xb4>
mov    0xc(%rsp),%edi
call   10a0 <S_ISBLK@plt>
test   %rax,%rax
je     127b <main+0xfb>
mov    0xc(%rsp),%edi
call   1090 <S_ISCHR@plt>
test   %rax,%rax
lea    0xdd1(%rip),%rbp
lea    0xdd4(%rip),%rax
cmove  %rax,%rbp
mov    0x8(%rsp),%edi
call   1070 <major@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%edi
call   1050 <minor@plt>
lea    0xd98(%rip),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11bc <main+0x3c>
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 = [12 x i8] c"stat error\0A\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"characher\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 i32
%7 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %8
8: ; preds = %61, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %64
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i8**, i8*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i64 @stat(i8* %23, %struct.stat* %7)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %12
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %61
28: ; preds = %12
%29 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 2
%30 = load i32, i32* %29
%31 = call i32 @major(i32 %30)
%32 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 2
%33 = load i32, i32* %32
%34 = call i32 @minor(i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %34)
%36 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%37 = load i32, i32* %36
%38 = call i64 @S_ISCHR(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %28
%41 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%42 = load i32, i32* %41
%43 = call i64 @S_ISBLK(i32 %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %59
45: ; preds = %40, %28
%46 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%47 = load i32, i32* %46
%48 = call i64 @S_ISCHR(i32 %47)
%49 = icmp ne i64 %48, 0
%50 = zext i1 %49 to i64
%51 = select i1 %49, 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)
%52 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%53 = load i32, i32* %52
%54 = call i32 @major(i32 %53)
%55 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%56 = load i32, i32* %55
%57 = call i32 @minor(i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %51, i32 %54, i32 %57)
br label %59
59: ; preds = %45, %40
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %61
61: ; preds = %59, %26
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %8
64: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
@.str = [5 x i8] c"%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"characher\00"
@.str.5 = [6 x i8] c"block\00"
@str = [11 x i8] c"stat error\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 %49
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
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %6, %46
%12 = phi i64 [ 1, %6 ], [ %47, %46 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %13
%17 = call i64 @stat(i8* %16, %struct.stat* %3)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %46
21: ; preds = %11
%22 = load i32, i32* %7
%23 = call i32 @major(i32 %22)
%24 = load i32, i32* %7
%25 = call i32 @minor(i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %25)
%27 = load i32, i32* %8
%28 = call i64 @S_ISCHR(i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %21
%31 = load i32, i32* %8
%32 = call i64 @S_ISBLK(i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %44, label %34
34: ; preds = %30, %21
%35 = load i32, i32* %8
%36 = call i64 @S_ISCHR(i32 %35)
%37 = icmp eq i64 %36, 0
%38 = select i1 %37, 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)
%39 = load i32, i32* %9
%40 = call i32 @major(i32 %39)
%41 = load i32, i32* %9
%42 = call i32 @minor(i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %38, i32 %40, i32 %42)
br label %44
44: ; preds = %34, %30
%45 = call i32 @putchar(i32 10)
br label %46
46: ; preds = %44, %19
%47 = add nuw nsw i64 %12, 1
%48 = icmp eq i64 %47, %10
br i1 %48, label %49, label %11
49: ; preds = %46, %2
ret i32 0
}