#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ PTHREAD_CANCEL_ENABLE;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_setcancelstate(int /*<<< orphan*/,
                                          int /*<<< orphan*/ *);
int /*<<< orphan*/ usleep(int);
void *transmitterFunction(void *data) {
  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
  FILE *usartFile;
  usartFile = fopen("/dev/ttyO4", "w");
  if (!usartFile)
    printf("Could not open USART port file\n");
  while (1) {
    fprintf(usartFile, "21,13,54,35,13,43,41,34,13,4,43,54,67,8,6,51,2,3\n");
    usleep(1000000);
  }
}


x86 assembly (clang, -O0):
<transmitterFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <pthread_setcancelstate@plt>
lea    0xe8b(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119c <transmitterFunction+0x4c>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
jmp    11a1 <transmitterFunction+0x51>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xf4240,%edi
call   1070 <usleep@plt>
jmp    11a1 <transmitterFunction+0x51>

x86 assembly (clang, -O2):
<transmitterFunction>:
push   %r14
push   %rbx
push   %rax
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <pthread_setcancelstate@plt>
lea    0xe95(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    118b <transmitterFunction+0x3b>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x31,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    $0xf4240,%edi
call   1070 <usleep@plt>
jmp    11a0 <transmitterFunction+0x50>

LLVM IR (-O0):
@PTHREAD_CANCEL_ENABLE = global i32 0
@.str = [11 x i8] c"/dev/ttyO4\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [32 x i8] c"Could not open USART port file\0A\00"
@.str.3 = [50 x i8] c"21,13,54,35,13,43,41,34,13,4,43,54,67,8,6,51,2,3\0A\00"
define i8* @transmitterFunction(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i32, i32* @PTHREAD_CANCEL_ENABLE
%5 = call i32 @pthread_setcancelstate(i32 %4, i32* null)
%6 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
br label %12
12: ; preds = %11, %12
%13 = load i32*, i32** %3
%14 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @usleep(i32 1000000)
br label %12
}

LLVM IR (-O2):
@PTHREAD_CANCEL_ENABLE = global i32 0
@.str = [11 x i8] c"/dev/ttyO4\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [50 x i8] c"21,13,54,35,13,43,41,34,13,4,43,54,67,8,6,51,2,3\0A\00"
@str = [31 x i8] c"Could not open USART port file\00"
define noalias i8* @transmitterFunction(i8* nocapture readnone %0) {
%2 = load i32, i32* @PTHREAD_CANCEL_ENABLE
%3 = tail call i32 @pthread_setcancelstate(i32 %2, i32* null)
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
br label %9
9: ; preds = %8, %9
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i64 49, i64 1, i32* %4)
%11 = tail call i32 @usleep(i32 1000000)
br label %9
}