#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;
};

/* Variables and functions */
scalar_t__ S_ISBLK(int /*<<< orphan*/);
int major(int /*<<< orphan*/);
scalar_t__ stat(char *, struct stat *);
int is_loop(char *dev) {
  struct stat st;
  int ret = 0;
  if (stat(dev, &st) == 0) {
    if (S_ISBLK(st.st_mode) && (major(st.st_rdev) == 7)) {
      ret = 1;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<is_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
jne    1189 <is_loop+0x59>
mov    -0xc(%rbp),%edi
call   1050 <S_ISBLK@plt>
cmp    $0x0,%rax
je     1184 <is_loop+0x54>
mov    -0x10(%rbp),%edi
call   1030 <major@plt>
cmp    $0x7,%eax
jne    1184 <is_loop+0x54>
movl   $0x1,-0x14(%rbp)
jmp    1189 <is_loop+0x59>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_loop>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rsi
call   1040 <stat@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    1165 <is_loop+0x35>
mov    0xc(%rsp),%edi
call   1050 <S_ISBLK@plt>
test   %rax,%rax
je     1165 <is_loop+0x35>
mov    0x8(%rsp),%edi
call   1030 <major@plt>
xor    %ebx,%ebx
cmp    $0x7,%eax
sete   %bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
define i32 @is_loop(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%5 = load i8*, i8** %2
%6 = call i64 @stat(i8* %5, %struct.stat* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %1
%9 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%10 = load i32, i32* %9
%11 = call i64 @S_ISBLK(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 @major(i32 %15)
%17 = icmp eq i32 %16, 7
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 1, i32* %4
br label %19
19: ; preds = %18, %13, %8
br label %20
20: ; preds = %19, %1
%21 = load i32, i32* %4
ret i32 %21
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
define i32 @is_loop(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i64 @stat(i8* %0, %struct.stat* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%8 = load i32, i32* %7
%9 = call i64 @S_ISBLK(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %6
%12 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @major(i32 %13)
%15 = icmp eq i32 %14, 7
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %11, %6, %1
%18 = phi i32 [ 0, %6 ], [ 0, %1 ], [ %16, %11 ]
ret i32 %18
}