#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*/ O_RDWR;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void Hi_IR_FUNC_TEST_003() {
  int fp = 0;
  printf("Hi_IR_FUNC_TEST_003 start...\n");
  printf("REMOTE codetype ...NEC with simple repeat code - uPD6121G\n");
  if (-1 == (fp = open("/dev/"
                       "Hi_IR",
                       O_RDWR))) {
    printf("Hi_IR_FUNC_TEST_003 ERROR:can not open %s device. read return %d\n",
           "Hi_IR", fp);
    return;
  }
  close(fp);
  close(fp);
  close(fp);
  if (-1 == (fp = open("/dev/"
                       "Hi_IR",
                       O_RDWR))) {
    printf("Hi_IR_FUNC_TEST_003 ERROR:can not open %s device. read return %d\n",
           "Hi_IR", fp);
    return;
  }
  close(fp);
  printf("Hi_IR_FUNC_TEST_003 pass.\n\n");
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
lea    0xeee(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    119f <Hi_IR_FUNC_TEST_003+0x6f>
mov    -0x4(%rbp),%edx
lea    0xed8(%rip),%rdi
lea    0xecb(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1211 <Hi_IR_FUNC_TEST_003+0xe1>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
lea    0xe92(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11fb <Hi_IR_FUNC_TEST_003+0xcb>
mov    -0x4(%rbp),%edx
lea    0xe7c(%rip),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1211 <Hi_IR_FUNC_TEST_003+0xe1>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r14
push   %rbx
push   %rax
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xf13(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e85(%rip),%r14
mov    (%r14),%esi
lea    0xe93(%rip),%rdi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     11bc <Hi_IR_FUNC_TEST_003+0x7c>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <close@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    (%r14),%esi
lea    0xe68(%rip),%rdi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     11bc <Hi_IR_FUNC_TEST_003+0x7c>
mov    %eax,%edi
call   1050 <close@plt>
lea    0xef4(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>
lea    0xe48(%rip),%rdi
lea    0xe3b(%rip),%rsi
mov    $0xffffffff,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Hi_IR_FUNC_TEST_003 start...\0A\00"
@.str.1 = [59 x i8] c"REMOTE codetype ...NEC with simple repeat code - uPD6121G\0A\00"
@.str.2 = [11 x i8] c"/dev/Hi_IR\00"
@O_RDWR = global i32 0
@.str.3 = [66 x i8] c"Hi_IR_FUNC_TEST_003 ERROR:can not open %s device. read return %d\0A\00"
@.str.4 = [6 x i8] c"Hi_IR\00"
@.str.5 = [28 x i8] c"Hi_IR_FUNC_TEST_003 pass.\0A\0A\00"
define void @Hi_IR_FUNC_TEST_003() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @O_RDWR
%5 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %4)
store i32 %5, i32* %1
%6 = icmp eq i32 -1, %5
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %8)
br label %27
10: ; preds = %0
%11 = load i32, i32* %1
%12 = call i32 @close(i32 %11)
%13 = load i32, i32* %1
%14 = call i32 @close(i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @close(i32 %15)
%17 = load i32, i32* @O_RDWR
%18 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %17)
store i32 %18, i32* %1
%19 = icmp eq i32 -1, %18
br i1 %19, label %20, label %23
20: ; preds = %10
%21 = load i32, i32* %1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %27
23: ; preds = %10
%24 = load i32, i32* %1
%25 = call i32 @close(i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %23, %20, %7
ret void
}

LLVM IR (-O2):
@.str.2 = [11 x i8] c"/dev/Hi_IR\00"
@O_RDWR = global i32 0
@.str.3 = [66 x i8] c"Hi_IR_FUNC_TEST_003 ERROR:can not open %s device. read return %d\0A\00"
@.str.4 = [6 x i8] c"Hi_IR\00"
@str = [29 x i8] c"Hi_IR_FUNC_TEST_003 start...\00"
@str.6 = [58 x i8] c"REMOTE codetype ...NEC with simple repeat code - uPD6121G\00"
@str.7 = [27 x i8] c"Hi_IR_FUNC_TEST_003 pass.\0A\00"
define void @Hi_IR_FUNC_TEST_003() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.6, i64 0, i64 0))
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 -1)
br label %20
8: ; preds = %0
%9 = tail call i32 @close(i32 %4)
%10 = tail call i32 @close(i32 %4)
%11 = tail call i32 @close(i32 %4)
%12 = load i32, i32* @O_RDWR
%13 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 -1)
br label %20
17: ; preds = %8
%18 = tail call i32 @close(i32 %13)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
br label %20
20: ; preds = %17, %15, %6
ret void
}