#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_cc;
};
typedef int /*<<< orphan*/ ios;

/* Variables and functions */
int B115200;
int CLOCAL;
int CREAD;
int CS8;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
int /*<<< orphan*/ bailout(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned char);
int /*<<< orphan*/ memset(struct termios *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int write(int, unsigned char *, int);
int main(int argc, char **argv) {
  int fd, i, n;
  unsigned char vvv[256], *scout;
  int rs232_fd;
  struct termios ios;
  rs232_fd = open("/dev/ttyUSB1", O_WRONLY);
  if (rs232_fd < 0)
    bailout("socket");
  memset(&ios, 0, sizeof(ios));
  ios.c_cflag = B115200 | CLOCAL | CREAD | CS8;
  ios.c_cc[VMIN] = 1;
  tcsetattr(rs232_fd, TCSANOW, &ios);
  for (i = 0; i < 256; i++)
    vvv[i] = i;
  i = 0;
  for (;;) {
    if ((n = write(rs232_fd, (vvv + i), 1)) > 0)
      fprintf(stderr, "%02x ", *(vvv + i));
    i++;
    if (i == 100) {
      i = 0;
    }
  }
  close(rs232_fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
lea    0xe77(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x12c(%rbp)
cmpl   $0x0,-0x12c(%rbp)
jge    11ad <main+0x4d>
lea    0xe65(%rip),%rdi
call   1030 <bailout@plt>
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%eax
mov    0x2dd0(%rip),%rcx
or     (%rcx),%eax
mov    0x2e07(%rip),%rcx
or     (%rcx),%eax
mov    0x2df6(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x140(%rbp)
mov    -0x138(%rbp),%rax
mov    0x2dd8(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x12c(%rbp),%edi
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
lea    -0x140(%rbp),%rdx
call   1070 <tcsetattr@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x100,-0x18(%rbp)
jge    124f <main+0xef>
mov    -0x18(%rbp),%eax
mov    %al,%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x120(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1224 <main+0xc4>
movl   $0x0,-0x18(%rbp)
mov    -0x12c(%rbp),%edi
lea    -0x120(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jle    12a1 <main+0x141>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
movslq -0x18(%rbp),%rax
lea    0xd80(%rip),%rsi
movzbl -0x120(%rbp,%rax,1),%edx
ff
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jne    12bb <main+0x15b>
movl   $0x0,-0x18(%rbp)
jmp    1256 <main+0xf6>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
lea    0xf7f(%rip),%rdi
call   1080 <open@plt>
mov    %eax,%r13d
test   %eax,%eax
jns    1199 <main+0x39>
lea    0xf79(%rip),%rdi
call   1030 <bailout@plt>
mov    %rsp,%rbx
xor    %r15d,%r15d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    0x2e03(%rip),%rax
mov    0x2de4(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e19(%rip),%rax
or     (%rax),%ecx
mov    0x2e08(%rip),%rax
or     (%rax),%ecx
mov    %ecx,(%rsp)
mov    0x8(%rsp),%rax
mov    0x2def(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
mov    %rbx,%rdx
call   1070 <tcsetattr@plt>
movaps 0xdfa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xdfe(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe02(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe06(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe0a(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe0e(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe12(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe16(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe17(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe18(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe19(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xe1a(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xe1b(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xe1c(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xe1d(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xe1e(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
mov    0x2cdf(%rip),%r12
lea    0xe2c(%rip),%r14
xor    %ebp,%ebp
jmp    12fa <main+0x19a>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0x64,%ebp
cmove  %r15d,%ebp
movslq %ebp,%rax
lea    (%rsp,%rax,1),%rbx
add    $0x10,%rbx
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
test   %eax,%eax
jle    12f0 <main+0x190>
mov    (%r12),%edi
movzbl (%rbx),%edx
mov    %r14,%rsi
call   1060 <fprintf@plt>
jmp    12f0 <main+0x190>

LLVM IR (-O0):
%struct.termios = type { i32, i32* }
@.str = [13 x i8] c"/dev/ttyUSB1\00"
@O_WRONLY = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@B115200 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@CS8 = global i32 0
@VMIN = global i64 0
@TCSANOW = global i32 0
@stderr = global i32 0
@.str.2 = [6 x i8] c"%02x \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca i8*
%11 = alloca i32
%12 = alloca %struct.termios
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @O_WRONLY
%14 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 %14, i32* %11
%15 = load i32, i32* %11
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @bailout(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %2
%20 = call i32 @memset(%struct.termios* %12, i32 0, i32 16)
%21 = load i32, i32* @B115200
%22 = load i32, i32* @CLOCAL
%23 = or i32 %21, %22
%24 = load i32, i32* @CREAD
%25 = or i32 %23, %24
%26 = load i32, i32* @CS8
%27 = or i32 %25, %26
%28 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
store i32 %27, i32* %28
%29 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 1
%30 = load i32*, i32** %29
%31 = load i64, i64* @VMIN
%32 = getelementptr inbounds i32, i32* %30, i64 %31
store i32 1, i32* %32
%33 = load i32, i32* %11
%34 = load i32, i32* @TCSANOW
%35 = call i32 @tcsetattr(i32 %33, i32 %34, %struct.termios* %12)
store i32 0, i32* %7
br label %36
36: ; preds = %45, %19
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 256
br i1 %38, label %39, label %48
39: ; preds = %36
%40 = load i32, i32* %7
%41 = trunc i32 %40 to i8
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 %43
store i8 %41, i8* %44
br label %45
45: ; preds = %39
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %36
48: ; preds = %36
store i32 0, i32* %7
br label %49
49: ; preds = %71, %48
%50 = load i32, i32* %11
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = call i32 @write(i32 %50, i8* %54, i32 1)
store i32 %55, i32* %8
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %65
57: ; preds = %49
%58 = load i32, i32* @stderr
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i8, i8* %62
%64 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %63)
br label %65
65: ; preds = %57, %49
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
%68 = load i32, i32* %7
%69 = icmp eq i32 %68, 100
br i1 %69, label %70, label %71
70: ; preds = %65
store i32 0, i32* %7
br label %71
71: ; preds = %70, %65
br label %49
}

LLVM IR (-O2):
%struct.termios = type { i32, i32* }
@.str = [13 x i8] c"/dev/ttyUSB1\00"
@O_WRONLY = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@B115200 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@CS8 = global i32 0
@VMIN = global i64 0
@TCSANOW = global i32 0
@stderr = global i32 0
@.str.2 = [6 x i8] c"%02x \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = alloca %struct.termios
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.termios* %4 to i8*
%7 = load i32, i32* @O_WRONLY
%8 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @bailout(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = call i32 @memset(%struct.termios* %4, i32 0, i32 16)
%14 = load i32, i32* @B115200
%15 = load i32, i32* @CLOCAL
%16 = or i32 %15, %14
%17 = load i32, i32* @CREAD
%18 = or i32 %16, %17
%19 = load i32, i32* @CS8
%20 = or i32 %18, %19
%21 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
store i32 %20, i32* %21
%22 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 1
%23 = load i32*, i32** %22
%24 = load i64, i64* @VMIN
%25 = getelementptr inbounds i32, i32* %23, i64 %24
store i32 1, i32* %25
%26 = load i32, i32* @TCSANOW
%27 = call i32 @tcsetattr(i32 %8, i32 %26, %struct.termios* %4)
%28 = bitcast [256 x i8]* %3 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %28
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 16
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %30
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 32
%32 = bitcast i8* %31 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %32
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 48
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %34
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 64
%36 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> <i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79>, <16 x i8>* %36
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 80
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> <i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91, i8 92, i8 93, i8 94, i8 95>, <16 x i8>* %38
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 96
%40 = bitcast i8* %39 to <16 x i8>*
store <16 x i8> <i8 96, i8 97, i8 98, i8 99, i8 100, i8 101, i8 102, i8 103, i8 104, i8 105, i8 106, i8 107, i8 108, i8 109, i8 110, i8 111>, <16 x i8>* %40
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 112
%42 = bitcast i8* %41 to <16 x i8>*
store <16 x i8> <i8 112, i8 113, i8 114, i8 115, i8 116, i8 117, i8 118, i8 119, i8 120, i8 121, i8 122, i8 123, i8 124, i8 125, i8 126, i8 127>, <16 x i8>* %42
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 128
%44 = bitcast i8* %43 to <16 x i8>*
store <16 x i8> <i8 -128, i8 -127, i8 -126, i8 -125, i8 -124, i8 -123, i8 -122, i8 -121, i8 -120, i8 -119, i8 -118, i8 -117, i8 -116, i8 -115, i8 -114, i8 -113>, <16 x i8>* %44
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 144
%46 = bitcast i8* %45 to <16 x i8>*
store <16 x i8> <i8 -112, i8 -111, i8 -110, i8 -109, i8 -108, i8 -107, i8 -106, i8 -105, i8 -104, i8 -103, i8 -102, i8 -101, i8 -100, i8 -99, i8 -98, i8 -97>, <16 x i8>* %46
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 160
%48 = bitcast i8* %47 to <16 x i8>*
store <16 x i8> <i8 -96, i8 -95, i8 -94, i8 -93, i8 -92, i8 -91, i8 -90, i8 -89, i8 -88, i8 -87, i8 -86, i8 -85, i8 -84, i8 -83, i8 -82, i8 -81>, <16 x i8>* %48
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 176
%50 = bitcast i8* %49 to <16 x i8>*
store <16 x i8> <i8 -80, i8 -79, i8 -78, i8 -77, i8 -76, i8 -75, i8 -74, i8 -73, i8 -72, i8 -71, i8 -70, i8 -69, i8 -68, i8 -67, i8 -66, i8 -65>, <16 x i8>* %50
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 192
%52 = bitcast i8* %51 to <16 x i8>*
store <16 x i8> <i8 -64, i8 -63, i8 -62, i8 -61, i8 -60, i8 -59, i8 -58, i8 -57, i8 -56, i8 -55, i8 -54, i8 -53, i8 -52, i8 -51, i8 -50, i8 -49>, <16 x i8>* %52
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 208
%54 = bitcast i8* %53 to <16 x i8>*
store <16 x i8> <i8 -48, i8 -47, i8 -46, i8 -45, i8 -44, i8 -43, i8 -42, i8 -41, i8 -40, i8 -39, i8 -38, i8 -37, i8 -36, i8 -35, i8 -34, i8 -33>, <16 x i8>* %54
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 224
%56 = bitcast i8* %55 to <16 x i8>*
store <16 x i8> <i8 -32, i8 -31, i8 -30, i8 -29, i8 -28, i8 -27, i8 -26, i8 -25, i8 -24, i8 -23, i8 -22, i8 -21, i8 -20, i8 -19, i8 -18, i8 -17>, <16 x i8>* %56
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 240
%58 = bitcast i8* %57 to <16 x i8>*
store <16 x i8> <i8 -16, i8 -15, i8 -14, i8 -13, i8 -12, i8 -11, i8 -10, i8 -9, i8 -8, i8 -7, i8 -6, i8 -5, i8 -4, i8 -3, i8 -2, i8 -1>, <16 x i8>* %58
br label %59
59: ; preds = %12, %69
%60 = phi i32 [ %72, %69 ], [ 0, %12 ]
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %61
%63 = call i32 @write(i32 %8, i8* %62, i32 1)
%64 = icmp sgt i32 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %59
%66 = load i32, i32* @stderr
%67 = load i8, i8* %62
%68 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %67)
br label %69
69: ; preds = %65, %59
%70 = add nsw i32 %60, 1
%71 = icmp eq i32 %70, 100
%72 = select i1 %71, i32 0, i32 %70
br label %59
}