#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ raw(int);
int /*<<< orphan*/ stderr;
int get_atari(void) {
  int fd;
  char portname[64] = "/dev/ttyS2";
  fd = open(portname, O_RDWR);
  if (fd < 0) {
    fprintf(stderr, "Can't open %s\n", portname);
    exit(1);
  }
  raw(fd);
  return (fd);
}


x86 assembly (clang, -O0):
<get_atari>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x50(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
lea    -0x50(%rbp),%rdi
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    11af <get_atari+0x5f>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rdx
lea    0xea0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
call   1030 <raw@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_atari>:
push   %rbx
sub    $0x40,%rsp
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe90(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1050 <open@plt>
test   %eax,%eax
js     119a <get_atari+0x5a>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <raw@plt>
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
mov    %rsp,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@__const.get_atari.portname = [64 x i8] c"/dev/ttyS2\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str = [15 x i8] c"Can't open %s\0A\00"
define i32 @get_atari() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = bitcast [64 x i8]* %2 to i8*
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @O_RDWR
%6 = call i32 @open(i8* %4, i32 %5)
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = load i32, i32* %1
%16 = call i32 @raw(i32 %15)
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@__const.get_atari.portname = [64 x i8] c"/dev/ttyS2\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str = [15 x i8] c"Can't open %s\0A\00"
define i32 @get_atari() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_RDWR
%4 = call i32 @open(i8* %2, i32 %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %2)
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = tail call i32 @raw(i32 %4)
ret i32 %4
}