#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 PATH_MAX;
int /*<<< orphan*/ logprintf(char *, char *);
int /*<<< orphan*/ qfprintf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ sysprintf(char *, char *);
void install_uimage(char *file) {
  char cmd[PATH_MAX];
  int code;
  int verbose_fd;
  char *dot;
  logprintf("0installing uImage file %s", file);
  dot = strchr(file, '.');
  if (dot == NULL)
    return;
  ++dot;
  sysprintf("cp %s /mnt/boot", file);
  sprintf(cmd, "/mnt/boot/moboot.verbose.%s", dot);
  qfprintf(cmd, "yes");
  return;
}


x86 assembly (clang, -O0):
<install_uimage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1070 <logprintf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c1 <install_uimage+0x71>
movl   $0x1,-0x2c(%rbp)
jmp    1208 <install_uimage+0xb8>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1040 <sysprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe3f(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1050 <qfprintf@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<install_uimage>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e8c(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0xe82(%rip),%rdi
mov    %r14,%rsi
call   1070 <logprintf@plt>
mov    %r14,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11cf <install_uimage+0x7f>
mov    %rax,%rbx
add    $0x1,%rbx
lea    0xe75(%rip),%rdi
mov    %r14,%rsi
call   1040 <sysprintf@plt>
lea    0xe76(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
lea    0xe80(%rip),%rsi
mov    %r15,%rdi
call   1050 <qfprintf@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [27 x i8] c"0installing uImage file %s\00"
@.str.1 = [16 x i8] c"cp %s /mnt/boot\00"
@.str.2 = [28 x i8] c"/mnt/boot/moboot.verbose.%s\00"
@.str.3 = [4 x i8] c"yes\00"
define void @install_uimage(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i32, i32* @PATH_MAX
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %3
%12 = alloca i8, i64 %10
store i64 %10, i64* %4
%13 = load i8*, i8** %2
%14 = call i32 @logprintf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %2
%16 = call i8* @strchr(i8* %15, i8 signext 46)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %1
store i32 1, i32* %8
br label %28
20: ; preds = %1
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %7
%23 = load i8*, i8** %2
%24 = call i32 @sysprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %7
%26 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = call i32 @qfprintf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %8
br label %28
28: ; preds = %20, %19
%29 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [27 x i8] c"0installing uImage file %s\00"
@.str.1 = [16 x i8] c"cp %s /mnt/boot\00"
@.str.2 = [28 x i8] c"/mnt/boot/moboot.verbose.%s\00"
@.str.3 = [4 x i8] c"yes\00"
define void @install_uimage(i8* %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = tail call i32 @logprintf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = tail call i32 @sysprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%12 = call i32 @qfprintf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %1, %8
ret void
}