#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 */
void *bmp_to_buffer(char *, int, int, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
void *bmp_to_buffer_800x480_24bits(int index) {
  void *buffer = NULL;
  char path[256] = "/mnt/sdcard";
  index = index > 0 ? index : -index;
  index = (index % 30);
  sprintf(path, "%s/%d.bmp", "/mnt/sdcard", index + 1);
  buffer = bmp_to_buffer(path, 800, 480, 24);
  return buffer;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x100,%edx
call   1030 <memcpy@plt>
cmpl   $0x0,-0x4(%rbp)
jle    1176 <bmp_to_buffer_800x480_24bits+0x46>
mov    -0x4(%rbp),%eax
mov    %eax,-0x114(%rbp)
jmp    1181 <bmp_to_buffer_800x480_24bits+0x51>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x1e,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
lea    0xf54(%rip),%rsi
lea    0xf57(%rip),%rdx
call   1050 <sprintf@plt>
lea    -0x110(%rbp),%rdi
mov    $0x320,%esi
mov    $0x1e0,%edx
mov    $0x18,%ecx
call   1040 <bmp_to_buffer@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %rbx
sub    $0x108,%rsp
mov    %edi,%ebp
lea    0xebe(%rip),%rsi
mov    %rsp,%rbx
mov    $0x100,%edx
mov    %rbx,%rdi
call   1030 <memcpy@plt>
mov    %ebp,%eax
neg    %eax
cmovs  %ebp,%eax
mov    $0x88888889,%ecx
imul   %rax,%rcx
shr    $0x24,%rcx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
lea    (%rax,%rsi,1),%ecx
add    $0x1,%ecx
lea    0xf82(%rip),%rsi
lea    0xf85(%rip),%rdx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    $0x320,%esi
mov    $0x1e0,%edx
mov    $0x18,%ecx
call   1040 <bmp_to_buffer@plt>
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.bmp_to_buffer_800x480_24bits.path = [256 x i8] c"/mnt/sdcard\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [10 x i8] c"%s/%d.bmp\00"
@.str.1 = [12 x i8] c"/mnt/sdcard\00"
define i8* @bmp_to_buffer_800x480_24bits(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [256 x i8]
store i32 %0, i32* %2
store i8* null, i8** %3
%5 = bitcast [256 x i8]* %4 to i8*
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i32, i32* %2
br label %13
10: ; preds = %1
%11 = load i32, i32* %2
%12 = sub nsw i32 0, %11
br label %13
13: ; preds = %10, %8
%14 = phi i32 [ %9, %8 ], [ %12, %10 ]
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = srem i32 %15, 30
store i32 %16, i32* %2
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
%20 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%22 = call i8* @bmp_to_buffer(i8* %21, i32 800, i32 480, i32 24)
store i8* %22, i8** %3
%23 = load i8*, i8** %3
ret i8* %23
}

LLVM IR (-O2):
@__const.bmp_to_buffer_800x480_24bits.path = [256 x i8] c"/mnt/sdcard\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [10 x i8] c"%s/%d.bmp\00"
@.str.1 = [12 x i8] c"/mnt/sdcard\00"
define i8* @bmp_to_buffer_800x480_24bits(i32 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%5 = urem i32 %4, 30
%6 = add nuw nsw i32 %5, 1
%7 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i8* @bmp_to_buffer(i8* %3, i32 800, i32 480, i32 24)
ret i8* %8
}