#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_SkipSpace(char *);
int /*<<< orphan*/ EEprom_Write_2(int, int);
int /*<<< orphan*/ U3_TxPuts(char *);
int atoi(char *);
int /*<<< orphan*/ csprintf(char *, char *, int);
int System_Current(char *buf) {
  char cmd[50];
  int curr;
  if (buf != NULL) {
    buf = Cmd_SkipSpace(buf);
    curr = atoi(buf);
    EEprom_Write_2(5, curr);
    csprintf(cmd, "current: 0\r\n", curr);
    U3_TxPuts(cmd);
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<System_Current>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b5 <System_Current+0x65>
mov    -0x10(%rbp),%rdi
call   1070 <Cmd_SkipSpace@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%esi
mov    $0x5,%edi
call   1050 <EEprom_Write_2@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%edx
lea    0xe65(%rip),%rsi
call   1030 <csprintf@plt>
lea    -0x50(%rbp),%rdi
call   1040 <U3_TxPuts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bc <System_Current+0x6c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<System_Current>:
test   %rdi,%rdi
je     119d <System_Current+0x4d>
push   %r14
push   %rbx
sub    $0x38,%rsp
call   1070 <Cmd_SkipSpace@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    $0x5,%edi
mov    %eax,%esi
call   1050 <EEprom_Write_2@plt>
lea    0xe82(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <csprintf@plt>
mov    %r14,%rdi
call   1040 <U3_TxPuts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@.str = [13 x i8] c"current: 0\0D\0A\00"
define i32 @System_Current(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [50 x i8]
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %20
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @Cmd_SkipSpace(i8* %9)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = call i32 @EEprom_Write_2(i32 5, i32 %13)
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%16 = load i32, i32* %5
%17 = call i32 @csprintf(i8* %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%19 = call i32 @U3_TxPuts(i8* %18)
store i32 0, i32* %2
br label %21
20: ; preds = %1
store i32 -1, i32* %2
br label %21
21: ; preds = %20, %8
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [13 x i8] c"current: 0\0D\0A\00"
define i32 @System_Current(i8* %0) {
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%4 = icmp eq i8* %0, null
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = tail call i8* @Cmd_SkipSpace(i8* %0)
%7 = tail call i32 @atoi(i8* %6)
%8 = tail call i32 @EEprom_Write_2(i32 5, i32 %7)
%9 = call i32 @csprintf(i8* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
%10 = call i32 @U3_TxPuts(i8* %3)
br label %11
11: ; preds = %1, %5
%12 = phi i32 [ 0, %5 ], [ -1, %1 ]
ret i32 %12
}