#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 */
typedef int int32_t;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int);
void divide_str_by_100(char *str, char *decimal_str) {
  int32_t result_int, result_frac;
  int32_t value_int;
  value_int = atoi(str);
  result_int = (int32_t)(value_int / 100);
  if (result_int < 0) {
    result_frac = -1 * (value_int % 100);
  } else {
    result_frac = value_int % 100;
  }
  snprintf(decimal_str, 8, "%d.%02u", result_int, result_frac);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    116d <divide_str_by_100+0x4d>
mov    -0x1c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
imul   $0xffffffff,%edx,%eax
mov    %eax,-0x18(%rbp)
jmp    117b <divide_str_by_100+0x5b>
mov    -0x1c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    $0x8,%esi
lea    0xe6e(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbx
mov    %rsi,%rbx
call   1040 <atoi@plt>
movslq %eax,%rcx
cmp    $0xffffff9c,%eax
jg     1143 <divide_str_by_100+0x23>
neg    %eax
imul   $0x51eb851f,%rax,%rdx
shr    $0x25,%rdx
imul   $0x64,%edx,%edx
jmp    115c <divide_str_by_100+0x3c>
imul   $0x51eb851f,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rax
add    %edx,%eax
imul   $0x64,%eax,%edx
mov    %ecx,%eax
sub    %edx,%eax
imul   $0x51eb851f,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
lea    0xe87(%rip),%rdx
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %eax,%r8d
pop    %rbx
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%d.%02u\00"
define void @divide_str_by_100(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @atoi(i8* %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = sdiv i32 %10, 100
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* %7
%16 = srem i32 %15, 100
%17 = mul nsw i32 -1, %16
store i32 %17, i32* %6
br label %21
18: ; preds = %2
%19 = load i32, i32* %7
%20 = srem i32 %19, 100
store i32 %20, i32* %6
br label %21
21: ; preds = %18, %14
%22 = load i8*, i8** %4
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 @snprintf(i8* %22, i32 8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d.%02u\00"
define void @divide_str_by_100(i8* nocapture %0, i8* %1) {
%3 = tail call i32 @atoi(i8* %0)
%4 = icmp slt i32 %3, -99
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = sub i32 0, %3
%7 = urem i32 %6, 100
br label %10
8: ; preds = %2
%9 = srem i32 %3, 100
br label %10
10: ; preds = %8, %5
%11 = phi i32 [ %7, %5 ], [ %9, %8 ]
%12 = sdiv i32 %3, 100
%13 = tail call i32 @snprintf(i8* %1, i32 8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %11)
ret void
}