#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 */
char *Cmd_SkipChars(char *);
char *Cmd_SkipSpace(char *);
int /*<<< orphan*/ EEprom_Write_2(int, int);
int /*<<< orphan*/ U1_TxPutsf(char *);
int /*<<< orphan*/ U3_TxPutsf(char *);
int atoi(char *);
scalar_t__ cstrcmp(char *, char *);
int Update_Rate(char *buf) {
  char *module;
  int rate;
  module = Cmd_SkipSpace(buf);
  buf = Cmd_SkipChars(module);
  *buf = 0;
  buf++;
  rate = atoi(buf);
  if (cstrcmp("temp", module) == 0) {
    EEprom_Write_2(3, rate);
    U1_TxPutsf("Temp updated");
    return 0;
  } else if (cstrcmp("current", module) == 0) {
    EEprom_Write_2(7, rate);
    U1_TxPutsf("Current updated");
    return 0;
  }
  if (cstrcmp("volt", module) == 0) {
    EEprom_Write_2(10, rate);
    U1_TxPutsf("Volt updated");
    return 0;
  }
  U3_TxPutsf("update: volt 0\r\n");
  U3_TxPutsf("update: current 1\r\n");
  U3_TxPutsf("update: temp 0\r\n");
  return -1;
}


x86 assembly (clang, -O0):
<Update_Rate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <Cmd_SkipSpace@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <Cmd_SkipChars@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1030 <cstrcmp@plt>
cmp    $0x0,%rax
jne    11f4 <Update_Rate+0x84>
mov    -0x1c(%rbp),%esi
mov    $0x3,%edi
call   1060 <EEprom_Write_2@plt>
lea    0xe22(%rip),%rdi
call   1040 <U1_TxPutsf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a2 <Update_Rate+0x132>
mov    -0x18(%rbp),%rsi
lea    0xe13(%rip),%rdi
call   1030 <cstrcmp@plt>
cmp    $0x0,%rax
jne    1233 <Update_Rate+0xc3>
mov    -0x1c(%rbp),%esi
mov    $0x7,%edi
call   1060 <EEprom_Write_2@plt>
lea    0xdf8(%rip),%rdi
call   1040 <U1_TxPutsf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a2 <Update_Rate+0x132>
jmp    1238 <Update_Rate+0xc8>
mov    -0x18(%rbp),%rsi
lea    0xde7(%rip),%rdi
call   1030 <cstrcmp@plt>
cmp    $0x0,%rax
jne    1277 <Update_Rate+0x107>
mov    -0x1c(%rbp),%esi
mov    $0xa,%edi
call   1060 <EEprom_Write_2@plt>
lea    0xdc9(%rip),%rdi
call   1040 <U1_TxPutsf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a2 <Update_Rate+0x132>
lea    0xdbe(%rip),%rdi
call   1050 <U3_TxPutsf@plt>
lea    0xdc3(%rip),%rdi
call   1050 <U3_TxPutsf@plt>
lea    0xdcb(%rip),%rdi
call   1050 <U3_TxPutsf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Update_Rate>:
push   %rbp
push   %rbx
push   %rax
call   1080 <Cmd_SkipSpace@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <Cmd_SkipChars@plt>
movb   $0x0,(%rax)
lea    0x1(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
lea    0xe68(%rip),%rdi
mov    %rbx,%rsi
call   1030 <cstrcmp@plt>
test   %rax,%rax
je     11f8 <Update_Rate+0x88>
lea    0xe66(%rip),%rdi
mov    %rbx,%rsi
call   1030 <cstrcmp@plt>
test   %rax,%rax
je     120d <Update_Rate+0x9d>
lea    0xe6a(%rip),%rdi
mov    %rbx,%rsi
call   1030 <cstrcmp@plt>
test   %rax,%rax
je     1222 <Update_Rate+0xb2>
lea    0xe68(%rip),%rdi
call   1050 <U3_TxPutsf@plt>
lea    0xe6d(%rip),%rdi
call   1050 <U3_TxPutsf@plt>
lea    0xe75(%rip),%rdi
call   1050 <U3_TxPutsf@plt>
mov    $0xffffffff,%eax
jmp    123c <Update_Rate+0xcc>
mov    $0x3,%edi
mov    %ebp,%esi
call   1060 <EEprom_Write_2@plt>
lea    0xdfa(%rip),%rdi
jmp    1235 <Update_Rate+0xc5>
mov    $0x7,%edi
mov    %ebp,%esi
call   1060 <EEprom_Write_2@plt>
lea    0xdfa(%rip),%rdi
jmp    1235 <Update_Rate+0xc5>
mov    $0xa,%edi
mov    %ebp,%esi
call   1060 <EEprom_Write_2@plt>
lea    0xdfa(%rip),%rdi
call   1040 <U1_TxPutsf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"temp\00"
@.str.1 = [13 x i8] c"Temp updated\00"
@.str.2 = [8 x i8] c"current\00"
@.str.3 = [16 x i8] c"Current updated\00"
@.str.4 = [5 x i8] c"volt\00"
@.str.5 = [13 x i8] c"Volt updated\00"
@.str.6 = [17 x i8] c"update: volt 0\0D\0A\00"
@.str.7 = [20 x i8] c"update: current 1\0D\0A\00"
@.str.8 = [17 x i8] c"update: temp 0\0D\0A\00"
define i32 @Update_Rate(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @Cmd_SkipSpace(i8* %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = call i8* @Cmd_SkipChars(i8* %8)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
store i8 0, i8* %10
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %5
%15 = load i8*, i8** %4
%16 = call i64 @cstrcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %1
%19 = load i32, i32* %5
%20 = call i32 @EEprom_Write_2(i32 3, i32 %19)
%21 = call i32 @U1_TxPutsf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %43
22: ; preds = %1
%23 = load i8*, i8** %4
%24 = call i64 @cstrcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* %5
%28 = call i32 @EEprom_Write_2(i32 7, i32 %27)
%29 = call i32 @U1_TxPutsf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %43
30: ; preds = %22
br label %31
31: ; preds = %30
%32 = load i8*, i8** %4
%33 = call i64 @cstrcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* %5
%37 = call i32 @EEprom_Write_2(i32 10, i32 %36)
%38 = call i32 @U1_TxPutsf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %43
39: ; preds = %31
%40 = call i32 @U3_TxPutsf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%41 = call i32 @U3_TxPutsf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%42 = call i32 @U3_TxPutsf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %2
br label %43
43: ; preds = %39, %35, %26, %18
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
@.str = [5 x i8] c"temp\00"
@.str.1 = [13 x i8] c"Temp updated\00"
@.str.2 = [8 x i8] c"current\00"
@.str.3 = [16 x i8] c"Current updated\00"
@.str.4 = [5 x i8] c"volt\00"
@.str.5 = [13 x i8] c"Volt updated\00"
@.str.6 = [17 x i8] c"update: volt 0\0D\0A\00"
@.str.7 = [20 x i8] c"update: current 1\0D\0A\00"
@.str.8 = [17 x i8] c"update: temp 0\0D\0A\00"
define i32 @Update_Rate(i8* %0) {
%2 = tail call i8* @Cmd_SkipSpace(i8* %0)
%3 = tail call i8* @Cmd_SkipChars(i8* %2)
store i8 0, i8* %3
%4 = getelementptr inbounds i8, i8* %3, i64 1
%5 = tail call i32 @atoi(i8* %4)
%6 = tail call i64 @cstrcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = tail call i32 @EEprom_Write_2(i32 3, i32 %5)
%10 = tail call i32 @U1_TxPutsf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %27
11: ; preds = %1
%12 = tail call i64 @cstrcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = tail call i32 @EEprom_Write_2(i32 7, i32 %5)
%16 = tail call i32 @U1_TxPutsf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %27
17: ; preds = %11
%18 = tail call i64 @cstrcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = tail call i32 @EEprom_Write_2(i32 10, i32 %5)
%22 = tail call i32 @U1_TxPutsf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %27
23: ; preds = %17
%24 = tail call i32 @U3_TxPutsf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%25 = tail call i32 @U3_TxPutsf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%26 = tail call i32 @U3_TxPutsf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %27
27: ; preds = %23, %20, %14, %8
%28 = phi i32 [ 0, %8 ], [ 0, %14 ], [ 0, %20 ], [ -1, %23 ]
ret i32 %28
}