#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*/ serialCommand(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ usleep(int);
void hr20GetTimer(int day, int slot, char *value) {
  char buffer[20];
  char response[255];
  char *result;
  sprintf(buffer, "\rR%d%d\r", day, slot);
  while (1) {
    serialCommand(buffer, response);
    if (response[0] == 'R')
      break;
    usleep(1000);
  }
  result = strtok(response, "=");
  result = strtok(NULL, "=");
  strcpy(value, result);
}


x86 assembly (clang, -O0):
<hr20GetTimer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe8a(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1040 <serialCommand@plt>
movsbl -0x130(%rbp),%eax
cmp    $0x52,%eax
jne    11a0 <hr20GetTimer+0x50>
jmp    11af <hr20GetTimer+0x5f>
mov    $0x3e8,%edi
call   1070 <usleep@plt>
jmp    117b <hr20GetTimer+0x2b>
lea    -0x130(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x138(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe34(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x138(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x138(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hr20GetTimer>:
push   %r15
push   %r14
push   %rbx
sub    $0x120,%rsp
mov    %rdx,%r14
mov    %esi,%ecx
mov    %edi,%edx
lea    0xe96(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <serialCommand@plt>
cmpb   $0x52,0x20(%rsp)
je     11bc <hr20GetTimer+0x6c>
mov    %rsp,%r15
lea    0x20(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x3e8,%edi
call   1070 <usleep@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <serialCommand@plt>
cmpb   $0x52,0x20(%rsp)
jne    11a0 <hr20GetTimer+0x50>
lea    0xe45(%rip),%rbx
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
call   1050 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <strtok@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
add    $0x120,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\0DR%d%d\0D\00"
@.str.1 = [2 x i8] c"=\00"
define void @hr20GetTimer(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [20 x i8]
%8 = alloca [255 x i8]
%9 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
br label %14
14: ; preds = %3, %23
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%17 = call i32 @serialCommand(i8* %15, i8* %16)
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 82
br i1 %21, label %22, label %23
22: ; preds = %14
br label %25
23: ; preds = %14
%24 = call i32 @usleep(i32 1000)
br label %14
25: ; preds = %22
%26 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%27 = call i8* @strtok(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %27, i8** %9
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %28, i8** %9
%29 = load i8*, i8** %6
%30 = load i8*, i8** %9
%31 = call i32 @strcpy(i8* %29, i8* %30)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"\0DR%d%d\0D\00"
@.str.1 = [2 x i8] c"=\00"
define void @hr20GetTimer(i32 %0, i32 %1, i8* %2) {
%4 = alloca [20 x i8]
%5 = alloca [255 x i8]
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%8 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%9 = call i32 @serialCommand(i8* %6, i8* %7)
%10 = load i8, i8* %7
%11 = icmp eq i8 %10, 82
br i1 %11, label %17, label %12
12: ; preds = %3, %12
%13 = call i32 @usleep(i32 1000)
%14 = call i32 @serialCommand(i8* %6, i8* %7)
%15 = load i8, i8* %7
%16 = icmp eq i8 %15, 82
br i1 %16, label %17, label %12
17: ; preds = %12, %3
%18 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @strcpy(i8* %2, i8* %19)
ret void
}