#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 atoi(char *);
scalar_t__ isupper(char);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int, ...);
char *strdup(char *);
char *getFloppyDesc(char *name) {
  int size;
  char *type;
  char desc[64];
  size = atoi(name + 1);
  if (isupper(name[0]))
    type = "3.5\"";
  else
    type = "5.25\"";
  if (size > 1000)
    snprintf(desc, 63, "%s %d.%dMB floppy drive", type, size / 1000,
             (size % 1000) / 10);
  else
    snprintf(desc, 64, "%s %dKB floppy drive", type, size);
  return strdup(desc);
}


x86 assembly (clang, -O0):
<getFloppyDesc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
call   1050 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     1182 <getFloppyDesc+0x42>
lea    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    118d <getFloppyDesc+0x4d>
lea    0xe7c(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jle    11e0 <getFloppyDesc+0xa0>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%eax
mov    $0x3e8,%esi
cltd
idiv   %esi
mov    %eax,%r8d
mov    -0xc(%rbp),%eax
mov    $0x3e8,%esi
cltd
idiv   %esi
mov    %edx,%eax
mov    $0xa,%esi
cltd
idiv   %esi
mov    %eax,%r9d
mov    $0x3f,%esi
lea    0xe37(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    11ff <getFloppyDesc+0xbf>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%r8d
mov    $0x40,%esi
lea    0xe2b(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    -0x60(%rbp),%rdi
call   1060 <strdup@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFloppyDesc>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%rbx
add    $0x1,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
movsbl (%rbx),%edi
call   1040 <isupper@plt>
test   %rax,%rax
lea    0xe9f(%rip),%rax
lea    0xe93(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x3e9,%ebp
jl     11b2 <getFloppyDesc+0x72>
mov    %ebp,%eax
imul   $0x10624dd3,%rax,%r8
shr    $0x26,%r8
imul   $0x3e8,%r8d,%eax
sub    %eax,%ebp
imul   $0xcccd,%ebp,%r9d
shr    $0x13,%r9d
lea    0xe6a(%rip),%rdx
mov    %rsp,%rdi
mov    $0x3f,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    11cb <getFloppyDesc+0x8b>
lea    0xe6a(%rip),%rdx
mov    %rsp,%rdi
mov    $0x40,%esi
mov    %ebp,%r8d
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %rsp,%rdi
call   1060 <strdup@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"3.5\22\00"
@.str.1 = [6 x i8] c"5.25\22\00"
@.str.2 = [24 x i8] c"%s %d.%dMB floppy drive\00"
@.str.3 = [21 x i8] c"%s %dKB floppy drive\00"
define i8* @getFloppyDesc(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [64 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = call i32 @atoi(i8* %7)
store i32 %8, i32* %3
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = call i64 @isupper(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %4
br label %16
15: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %16
16: ; preds = %15, %14
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, 1000
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%21 = load i8*, i8** %4
%22 = load i32, i32* %3
%23 = sdiv i32 %22, 1000
%24 = load i32, i32* %3
%25 = srem i32 %24, 1000
%26 = sdiv i32 %25, 10
%27 = call i32 (i8*, i32, i8*, i8*, i32, ...) @snprintf(i8* %20, i32 63, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %21, i32 %23, i32 %26)
br label %33
28: ; preds = %16
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%30 = load i8*, i8** %4
%31 = load i32, i32* %3
%32 = call i32 (i8*, i32, i8*, i8*, i32, ...) @snprintf(i8* %29, i32 64, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %30, i32 %31)
br label %33
33: ; preds = %28, %19
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%35 = call i8* @strdup(i8* %34)
ret i8* %35
}

LLVM IR (-O2):
@.str = [5 x i8] c"3.5\22\00"
@.str.1 = [6 x i8] c"5.25\22\00"
@.str.2 = [24 x i8] c"%s %d.%dMB floppy drive\00"
@.str.3 = [21 x i8] c"%s %dKB floppy drive\00"
define noalias i8* @getFloppyDesc(i8* nocapture %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = tail call i32 @atoi(i8* %4)
%6 = load i8, i8* %0
%7 = tail call i64 @isupper(i8 signext %6)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0)
%10 = icmp sgt i32 %5, 1000
br i1 %10, label %11, label %18
11: ; preds = %1
%12 = udiv i32 %5, 1000
%13 = urem i32 %5, 1000
%14 = trunc i32 %13 to i16
%15 = udiv i16 %14, 10
%16 = zext i16 %15 to i32
%17 = call i32 (i8*, i32, i8*, i8*, i32, ...) @snprintf(i8* %3, i32 63, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %9, i32 %12, i32 %16)
br label %20
18: ; preds = %1
%19 = call i32 (i8*, i32, i8*, i8*, i32, ...) @snprintf(i8* %3, i32 64, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %5)
br label %20
20: ; preds = %18, %11
%21 = call i8* @strdup(i8* %3)
ret i8* %21
}