#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 termios {
  int c_cflag;
  int c_lflag;
};

/* Variables and functions */
int /*<<< orphan*/ B19200;
int CLOCAL;
int CREAD;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int ICANON;
int ISIG;
int PARENB;
int /*<<< orphan*/ TCSANOW;
int atoi(char *);
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ msleep(unsigned int);
int open_port();
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  int red = atoi(argv[1]);
  int green = atoi(argv[2]);
  int blue = atoi(argv[3]);
  printf("%i %i %i\n", red, blue, green);
  int fd = open_port();
  struct termios options;
  tcgetattr(fd, &options);
  cfsetispeed(&options, B19200);
  cfsetospeed(&options, B19200);
  options.c_cflag |= (CLOCAL | CREAD);
  tcsetattr(fd, TCSANOW, &options);
  options.c_cflag &= ~CSIZE;
  options.c_cflag |= CS8;
  options.c_cflag &= ~PARENB;
  options.c_cflag &= ~CSTOPB;
  options.c_cflag &= ~CSIZE;
  options.c_cflag |= CS8;
  options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
  int n;
  unsigned int t = 0;
  char *a = (char *)&t;
  write(fd, "X", 1);
  unsigned int sleeptime = 10;
  write(fd, "r", 1);
  t = red;
  a = (char *)&t;
  write(fd, a, 1);
  msleep(sleeptime);
  write(fd, "g", 1);
  t = green;
  a = (char *)&t;
  write(fd, a, 1);
  msleep(sleeptime);
  write(fd, "b", 1);
  t = blue;
  a = (char *)&t;
  write(fd, a, 1);
  msleep(sleeptime);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe21(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   10b0 <open_port@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1070 <tcgetattr@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1090 <cfsetispeed@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    0x2d8a(%rip),%rcx
or     (%rcx),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2d98(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1080 <tcsetattr@plt>
mov    0x2d56(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d11(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d07(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2ce0(%rip),%rax
mov    (%rax),%eax
mov    0x2d0f(%rip),%rcx
or     (%rcx),%eax
mov    0x2cfe(%rip),%rcx
or     (%rcx),%eax
mov    0x2ced(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x30(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
lea    0xd13(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movl   $0xa,-0x3c(%rbp)
mov    -0x20(%rbp),%edi
lea    0xcfa(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%edi
call   1050 <msleep@plt>
mov    -0x20(%rbp),%edi
lea    0xcc1(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%edi
call   1050 <msleep@plt>
mov    -0x20(%rbp),%edi
lea    0xc88(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%edi
call   1050 <msleep@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r12d
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r15d
mov    0x18(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
lea    0xe34(%rip),%rdi
mov    %r12d,%esi
mov    %eax,%edx
mov    %r15d,%ecx
call   1060 <printf@plt>
xor    %eax,%eax
call   10b0 <open_port@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%r13
mov    %eax,%edi
mov    %r13,%rsi
call   1070 <tcgetattr@plt>
mov    0x2df8(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %r13,%rdi
call   1090 <cfsetispeed@plt>
mov    0x0(%rbp),%esi
mov    %r13,%rdi
call   1040 <cfsetospeed@plt>
mov    0x2d6b(%rip),%rax
mov    0x2d9c(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     %ecx,0x10(%rsp)
mov    0x2dad(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r13,%rdx
call   1080 <tcsetattr@plt>
mov    0x2d6a(%rip),%rax
mov    0x2d9b(%rip),%rcx
mov    0x2d3c(%rip),%rdx
mov    (%rdx),%edx
or     (%rax),%edx
or     (%rcx),%edx
not    %edx
and    0x10(%rsp),%edx
mov    0x2d51(%rip),%rax
or     (%rax),%edx
mov    0x2d30(%rip),%rax
mov    0x2d61(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d4e(%rip),%rax
or     (%rax),%ecx
mov    %edx,0x10(%rsp)
mov    0x2d39(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x14(%rsp)
lea    0xd74(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
lea    0xd63(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %r12d,0xc(%rsp)
lea    0xc(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0xa,%edi
call   1050 <msleep@plt>
lea    0xd2f(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %r15d,0xc(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0xa,%edi
call   1050 <msleep@plt>
lea    0xd00(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %r14d,0xc(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0xa,%edi
call   1050 <msleep@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32 }
@.str = [10 x i8] c"%i %i %i\0A\00"
@B19200 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"g\00"
@.str.4 = [2 x i8] c"b\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.termios
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %5
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i64 3
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %7
%26 = load i32, i32* %5
%27 = load i32, i32* %7
%28 = load i32, i32* %6
%29 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27, i32 %28)
%30 = call i32 (...) @open_port()
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = call i32 @tcgetattr(i32 %31, %struct.termios* %9)
%33 = load i32, i32* @B19200
%34 = call i32 @cfsetispeed(%struct.termios* %9, i32 %33)
%35 = load i32, i32* @B19200
%36 = call i32 @cfsetospeed(%struct.termios* %9, i32 %35)
%37 = load i32, i32* @CLOCAL
%38 = load i32, i32* @CREAD
%39 = or i32 %37, %38
%40 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%41 = load i32, i32* %40
%42 = or i32 %41, %39
store i32 %42, i32* %40
%43 = load i32, i32* %8
%44 = load i32, i32* @TCSANOW
%45 = call i32 @tcsetattr(i32 %43, i32 %44, %struct.termios* %9)
%46 = load i32, i32* @CSIZE
%47 = xor i32 %46, -1
%48 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%49 = load i32, i32* %48
%50 = and i32 %49, %47
store i32 %50, i32* %48
%51 = load i32, i32* @CS8
%52 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%53 = load i32, i32* %52
%54 = or i32 %53, %51
store i32 %54, i32* %52
%55 = load i32, i32* @PARENB
%56 = xor i32 %55, -1
%57 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%58 = load i32, i32* %57
%59 = and i32 %58, %56
store i32 %59, i32* %57
%60 = load i32, i32* @CSTOPB
%61 = xor i32 %60, -1
%62 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%63 = load i32, i32* %62
%64 = and i32 %63, %61
store i32 %64, i32* %62
%65 = load i32, i32* @CSIZE
%66 = xor i32 %65, -1
%67 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%68 = load i32, i32* %67
%69 = and i32 %68, %66
store i32 %69, i32* %67
%70 = load i32, i32* @CS8
%71 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%72 = load i32, i32* %71
%73 = or i32 %72, %70
store i32 %73, i32* %71
%74 = load i32, i32* @ICANON
%75 = load i32, i32* @ECHO
%76 = or i32 %74, %75
%77 = load i32, i32* @ECHOE
%78 = or i32 %76, %77
%79 = load i32, i32* @ISIG
%80 = or i32 %78, %79
%81 = xor i32 %80, -1
%82 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 1
%83 = load i32, i32* %82
%84 = and i32 %83, %81
store i32 %84, i32* %82
store i32 0, i32* %11
%85 = bitcast i32* %11 to i8*
store i8* %85, i8** %12
%86 = load i32, i32* %8
%87 = call i32 @write(i32 %86, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
store i32 10, i32* %13
%88 = load i32, i32* %8
%89 = call i32 @write(i32 %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%90 = load i32, i32* %5
store i32 %90, i32* %11
%91 = bitcast i32* %11 to i8*
store i8* %91, i8** %12
%92 = load i32, i32* %8
%93 = load i8*, i8** %12
%94 = call i32 @write(i32 %92, i8* %93, i32 1)
%95 = load i32, i32* %13
%96 = call i32 @msleep(i32 %95)
%97 = load i32, i32* %8
%98 = call i32 @write(i32 %97, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%99 = load i32, i32* %6
store i32 %99, i32* %11
%100 = bitcast i32* %11 to i8*
store i8* %100, i8** %12
%101 = load i32, i32* %8
%102 = load i8*, i8** %12
%103 = call i32 @write(i32 %101, i8* %102, i32 1)
%104 = load i32, i32* %13
%105 = call i32 @msleep(i32 %104)
%106 = load i32, i32* %8
%107 = call i32 @write(i32 %106, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%108 = load i32, i32* %7
store i32 %108, i32* %11
%109 = bitcast i32* %11 to i8*
store i8* %109, i8** %12
%110 = load i32, i32* %8
%111 = load i8*, i8** %12
%112 = call i32 @write(i32 %110, i8* %111, i32 1)
%113 = load i32, i32* %13
%114 = call i32 @msleep(i32 %113)
ret i32 0
}

LLVM IR (-O2):
%struct.termios = type { i32, i32 }
@.str = [10 x i8] c"%i %i %i\0A\00"
@B19200 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"g\00"
@.str.4 = [2 x i8] c"b\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.termios
%4 = alloca i32
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %13, i32 %10)
%15 = tail call i32 (...) @open_port()
%16 = bitcast %struct.termios* %3 to i8*
%17 = call i32 @tcgetattr(i32 %15, %struct.termios* %3)
%18 = load i32, i32* @B19200
%19 = call i32 @cfsetispeed(%struct.termios* %3, i32 %18)
%20 = load i32, i32* @B19200
%21 = call i32 @cfsetospeed(%struct.termios* %3, i32 %20)
%22 = load i32, i32* @CLOCAL
%23 = load i32, i32* @CREAD
%24 = or i32 %23, %22
%25 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%26 = load i32, i32* %25
%27 = or i32 %24, %26
store i32 %27, i32* %25
%28 = load i32, i32* @TCSANOW
%29 = call i32 @tcsetattr(i32 %15, i32 %28, %struct.termios* %3)
%30 = load i32, i32* @CSIZE
%31 = load i32, i32* %25
%32 = load i32, i32* @CS8
%33 = load i32, i32* @PARENB
%34 = load i32, i32* @CSTOPB
%35 = or i32 %34, %30
%36 = or i32 %33, %35
%37 = xor i32 %36, -1
%38 = and i32 %31, %37
%39 = or i32 %32, %38
store i32 %39, i32* %25
%40 = load i32, i32* @ICANON
%41 = load i32, i32* @ECHO
%42 = or i32 %41, %40
%43 = load i32, i32* @ECHOE
%44 = or i32 %42, %43
%45 = load i32, i32* @ISIG
%46 = or i32 %44, %45
%47 = xor i32 %46, -1
%48 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
%49 = load i32, i32* %48
%50 = and i32 %49, %47
store i32 %50, i32* %48
%51 = bitcast i32* %4 to i8*
%52 = call i32 @write(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%53 = call i32 @write(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
store i32 %7, i32* %4
%54 = call i32 @write(i32 %15, i8* %51, i32 1)
%55 = call i32 @msleep(i32 10)
%56 = call i32 @write(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
store i32 %10, i32* %4
%57 = call i32 @write(i32 %15, i8* %51, i32 1)
%58 = call i32 @msleep(i32 10)
%59 = call i32 @write(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
store i32 %13, i32* %4
%60 = call i32 @write(i32 %15, i8* %51, i32 1)
%61 = call i32 @msleep(i32 10)
ret i32 0
}