#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 B19200;
int B9600;
int CLOCAL;
int CREAD;
int CS8;
int HUPCL;
int /*<<< orphan*/ setspeed(int, int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
void I_wacom_reset_wacom(int fd) {
  setspeed(fd, 1200, 19200, 0, B19200 | CS8 | CREAD | CLOCAL | HUPCL);
  write(fd, "\r$", strlen("\r$"));
  usleep(250000);
  write(fd, "#\r", strlen("#\r"));
  usleep(75000);
  setspeed(fd, 1200, 9600, 0, B9600 | CS8 | CREAD | CLOCAL | HUPCL);
  write(fd, "#\r", strlen("#\r"));
  usleep(250000);
  write(fd, "\nSP\r", strlen("\nSP\r"));
  usleep(100000);
}


x86 assembly (clang, -O0):
<I_wacom_reset_wacom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e9b(%rip),%rax
mov    (%rax),%r8d
mov    0x2e71(%rip),%rax
or     (%rax),%r8d
mov    0x2e6f(%rip),%rax
or     (%rax),%r8d
mov    0x2e3d(%rip),%rax
or     (%rax),%r8d
mov    0x2e43(%rip),%rax
or     (%rax),%r8d
mov    $0x4b0,%esi
mov    $0x4b00,%edx
xor    %ecx,%ecx
call   1040 <setspeed@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xe62(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%edx
lea    0xe51(%rip),%rsi
call   1030 <write@plt>
mov    $0x3d090,%edi
call   1060 <usleep@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    0xe38(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%edx
lea    0xe27(%rip),%rsi
call   1030 <write@plt>
mov    $0x124f8,%edi
call   1060 <usleep@plt>
mov    -0x4(%rbp),%edi
mov    0x2deb(%rip),%rax
mov    (%rax),%r8d
mov    0x2dd1(%rip),%rax
or     (%rax),%r8d
mov    0x2dcf(%rip),%rax
or     (%rax),%r8d
mov    0x2d9d(%rip),%rax
or     (%rax),%r8d
mov    0x2da3(%rip),%rax
or     (%rax),%r8d
mov    $0x4b0,%esi
mov    $0x2580,%edx
xor    %ecx,%ecx
call   1040 <setspeed@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    0xdc5(%rip),%rdi
call   1050 <strlen@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%edx
lea    0xdb4(%rip),%rsi
call   1030 <write@plt>
mov    $0x3d090,%edi
call   1060 <usleep@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xd9b(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%edx
lea    0xd8a(%rip),%rsi
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1060 <usleep@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I_wacom_reset_wacom>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e9e(%rip),%rax
mov    0x2e77(%rip),%r15
mov    (%r15),%r8d
or     (%rax),%r8d
mov    0x2e72(%rip),%r12
or     (%r12),%r8d
mov    0x2e3f(%rip),%r13
or     0x0(%r13),%r8d
mov    %edi,%ebx
mov    0x2e42(%rip),%rbp
or     0x0(%rbp),%r8d
mov    $0x4b0,%esi
mov    $0x4b00,%edx
xor    %ecx,%ecx
call   1040 <setspeed@plt>
lea    0xe66(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x3d090,%edi
call   1060 <usleep@plt>
lea    0xe44(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x124f8,%edi
call   1060 <usleep@plt>
mov    0x2dfc(%rip),%rax
mov    (%r15),%r8d
or     (%rax),%r8d
or     (%r12),%r8d
or     0x0(%r13),%r8d
or     0x0(%rbp),%r8d
mov    %ebx,%edi
mov    $0x4b0,%esi
mov    $0x2580,%edx
xor    %ecx,%ecx
call   1040 <setspeed@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x3d090,%edi
call   1060 <usleep@plt>
lea    0xdd8(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <usleep@plt>

LLVM IR (-O0):
@B19200 = global i32 0
@CS8 = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@HUPCL = global i32 0
@.str = [3 x i8] c"\0D$\00"
@.str.1 = [3 x i8] c"#\0D\00"
@B9600 = global i32 0
@.str.2 = [5 x i8] c"\0ASP\0D\00"
define void @I_wacom_reset_wacom(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @B19200
%5 = load i32, i32* @CS8
%6 = or i32 %4, %5
%7 = load i32, i32* @CREAD
%8 = or i32 %6, %7
%9 = load i32, i32* @CLOCAL
%10 = or i32 %8, %9
%11 = load i32, i32* @HUPCL
%12 = or i32 %10, %11
%13 = call i32 @setspeed(i32 %3, i32 1200, i32 19200, i32 0, i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @write(i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 @usleep(i32 250000)
%18 = load i32, i32* %2
%19 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @write(i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 @usleep(i32 75000)
%22 = load i32, i32* %2
%23 = load i32, i32* @B9600
%24 = load i32, i32* @CS8
%25 = or i32 %23, %24
%26 = load i32, i32* @CREAD
%27 = or i32 %25, %26
%28 = load i32, i32* @CLOCAL
%29 = or i32 %27, %28
%30 = load i32, i32* @HUPCL
%31 = or i32 %29, %30
%32 = call i32 @setspeed(i32 %22, i32 1200, i32 9600, i32 0, i32 %31)
%33 = load i32, i32* %2
%34 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @write(i32 %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = call i32 @usleep(i32 250000)
%37 = load i32, i32* %2
%38 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @write(i32 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = call i32 @usleep(i32 100000)
ret void
}

LLVM IR (-O2):
@B19200 = global i32 0
@CS8 = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@HUPCL = global i32 0
@.str = [3 x i8] c"\0D$\00"
@.str.1 = [3 x i8] c"#\0D\00"
@B9600 = global i32 0
@.str.2 = [5 x i8] c"\0ASP\0D\00"
define void @I_wacom_reset_wacom(i32 %0) {
%2 = load i32, i32* @B19200
%3 = load i32, i32* @CS8
%4 = or i32 %3, %2
%5 = load i32, i32* @CREAD
%6 = or i32 %4, %5
%7 = load i32, i32* @CLOCAL
%8 = or i32 %6, %7
%9 = load i32, i32* @HUPCL
%10 = or i32 %8, %9
%11 = tail call i32 @setspeed(i32 %0, i32 1200, i32 19200, i32 0, i32 %10)
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 @usleep(i32 250000)
%15 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = tail call i32 @usleep(i32 75000)
%18 = load i32, i32* @B9600
%19 = load i32, i32* @CS8
%20 = or i32 %19, %18
%21 = load i32, i32* @CREAD
%22 = or i32 %20, %21
%23 = load i32, i32* @CLOCAL
%24 = or i32 %22, %23
%25 = load i32, i32* @HUPCL
%26 = or i32 %24, %25
%27 = tail call i32 @setspeed(i32 %0, i32 1200, i32 9600, i32 0, i32 %26)
%28 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%29 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = tail call i32 @usleep(i32 250000)
%31 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%32 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = tail call i32 @usleep(i32 100000)
ret void
}