#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*/);
scalar_t__ lstat(char *, struct stat *);
int major(int /*<<< orphan*/);
int minor(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int i;
  struct stat statbuf;
  if (argc < 2) {
    printf("usage:version <file1> <file2>\n");
    return 0;
  }
  for (i = 1; i < argc; i++) {
    if (lstat(argv[i], &statbuf) < 0) {
      perror(argv[i]);
      continue;
    }
    printf("%s:%d/%d\n", "dev", major(statbuf.st_dev), minor(statbuf.st_dev));
    if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
      printf("%s:%d/%d\n", S_ISBLK(statbuf.st_mode) ? "block" : "character",
             major(statbuf.st_rdev), minor(statbuf.st_rdev));
    }
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    11aa <main+0x3a>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ac <main+0x13c>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a5 <main+0x135>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <lstat@plt>
cmp    $0x0,%rax
jge    11f2 <main+0x82>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <perror@plt>
jmp    1297 <main+0x127>
mov    -0x18(%rbp),%edi
call   1050 <major@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <minor@plt>
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
lea    0xe0e(%rip),%rdi
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1080 <S_ISBLK@plt>
cmp    $0x0,%rax
jne    1243 <main+0xd3>
mov    -0x1c(%rbp),%edi
call   1070 <S_ISCHR@plt>
cmp    $0x0,%rax
je     1292 <main+0x122>
mov    -0x1c(%rbp),%edi
call   1080 <S_ISBLK@plt>
mov    %rax,%rdx
lea    0xdde(%rip),%rax
lea    0xdd1(%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    0xd94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1297 <main+0x127>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b1 <main+0x41>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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
jge    11b0 <main+0x30>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r13
mov    %edi,%r14d
mov    $0x1,%r15d
jmp    1210 <main+0x90>
xchg   %ax,%ax
mov    %ebp,%edi
call   1090 <S_ISBLK@plt>
test   %rax,%rax
lea    0xe3d(%rip),%rbx
lea    0xe3c(%rip),%rax
cmove  %rax,%rbx
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1060 <major@plt>
mov    %eax,%r12d
mov    %ebp,%edi
call   1040 <minor@plt>
lea    0xe08(%rip),%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     119f <main+0x1f>
mov    0x0(%r13,%r15,8),%rdi
lea    0x8(%rsp),%rsi
call   1070 <lstat@plt>
test   %rax,%rax
js     1277 <main+0xf7>
mov    0x10(%rsp),%ebp
mov    %ebp,%edi
call   1060 <major@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <minor@plt>
lea    0xdc1(%rip),%rdi
lea    0xdc4(%rip),%rsi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
call   1090 <S_ISBLK@plt>
test   %rax,%rax
jne    11c0 <main+0x40>
mov    %ebp,%edi
call   1080 <S_ISCHR@plt>
test   %rax,%rax
jne    11c0 <main+0x40>
jmp    1207 <main+0x87>
mov    0x0(%r13,%r15,8),%rdi
call   10a0 <perror@plt>
jmp    1207 <main+0x87>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
@.str = [31 x i8] c"usage:version <file1> <file2>\0A\00"
@.str.1 = [10 x i8] c"%s:%d/%d\0A\00"
@.str.2 = [4 x i8] c"dev\00"
@.str.3 = [6 x i8] c"block\00"
@.str.4 = [10 x i8] c"character\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
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %68
12: ; preds = %2
store i32 1, i32* %6
br label %13
13: ; preds = %64, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %67
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 @lstat(i8* %22, %struct.stat* %7)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %17
%26 = load i8**, i8*** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @perror(i8* %30)
br label %64
32: ; preds = %17
%33 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 2
%34 = load i32, i32* %33
%35 = call i32 @major(i32 %34)
%36 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 2
%37 = load i32, i32* %36
%38 = call i32 @minor(i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %38)
%40 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%41 = load i32, i32* %40
%42 = call i64 @S_ISBLK(i32 %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %32
%45 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%46 = load i32, i32* %45
%47 = call i64 @S_ISCHR(i32 %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %63
49: ; preds = %44, %32
%50 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%51 = load i32, i32* %50
%52 = call i64 @S_ISBLK(i32 %51)
%53 = icmp ne i64 %52, 0
%54 = zext i1 %53 to i64
%55 = select i1 %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0)
%56 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%57 = load i32, i32* %56
%58 = call i32 @major(i32 %57)
%59 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%60 = load i32, i32* %59
%61 = call i32 @minor(i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %55, i32 %58, i32 %61)
br label %63
63: ; preds = %49, %44
br label %64
64: ; preds = %63, %25
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %13
67: ; preds = %13
store i32 0, i32* %3
br label %68
68: ; preds = %67, %10
%69 = load i32, i32* %3
ret i32 %69
}

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