#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 */

/* Variables and functions */
int /*<<< orphan*/ _IO(char, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int stop_cmd(int device_fd) {
  int result, i;
  for (i = 0; i < 1; i++) {
    result = ioctl(device_fd, _IO('k', 4), 0);
    if (result < 0) {
      fprintf(stderr, "i2c: cannot access to the MCU\n");
      return -5;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<stop_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jge    11ae <stop_cmd+0x7e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x6b,%edi
mov    $0x4,%esi
call   1030 <_IO@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
xor    %edx,%edx
call   1040 <ioctl@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    119b <stop_cmd+0x6b>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xfffffffb,-0x4(%rbp)
jmp    11b5 <stop_cmd+0x85>
jmp    11a0 <stop_cmd+0x70>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1142 <stop_cmd+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stop_cmd>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x6b,%edi
mov    $0x4,%esi
call   1030 <_IO@plt>
xor    %ebx,%ebx
mov    %ebp,%edi
mov    %eax,%esi
xor    %edx,%edx
call   1040 <ioctl@plt>
test   %eax,%eax
jns    116f <stop_cmd+0x3f>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xfffffffb,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"i2c: cannot access to the MCU\0A\00"
define i32 @stop_cmd(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %5
br label %6
6: ; preds = %19, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %3
%11 = call i32 @_IO(i8 signext 107, i32 4)
%12 = call i32 @ioctl(i32 %10, i32 %11, i32 0)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 -5, i32* %2
br label %23
18: ; preds = %9
br label %19
19: ; preds = %18
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %6
22: ; preds = %6
store i32 0, i32* %2
br label %23
23: ; preds = %22, %15
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"i2c: cannot access to the MCU\0A\00"
define i32 @stop_cmd(i32 %0) {
%2 = tail call i32 @_IO(i8 signext 107, i32 4)
%3 = tail call i32 @ioctl(i32 %0, i32 %2, i32 0)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %1, %5
%9 = phi i32 [ -5, %5 ], [ 0, %1 ]
ret i32 %9
}