#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ free(char *);
char *malloc(int);
char *realloc(char *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ testAlloc(char *);
void prevodDoVystupni(unsigned long int desCislo, int s2) {
  int i = 0;
  int zbytek;
  char *cislo = NULL;
  const int INCREMENT = 10;
  int velikostBloku = 0;
  velikostBloku = INCREMENT;
  cislo = malloc(velikostBloku * sizeof(char));
  testAlloc(cislo);
  do {
    zbytek = desCislo % s2;
    desCislo = desCislo / s2;
    if (zbytek > 9)
      cislo[i] = zbytek + '7';
    else
      cislo[i] = zbytek + '0';
    i++;
    if ((i % velikostBloku) == 0) {
      velikostBloku += INCREMENT;
      cislo = realloc(cislo, velikostBloku);
      testAlloc(cislo);
    }
  } while (desCislo > 0);
  for (i--; i >= 0; i--) {
    fprintf(stdout, "%c", cislo[i]);
  }
  free(cislo);
}


x86 assembly (clang, -O0):
<prevodDoVystupni>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0xa,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0xa,-0x28(%rbp)
movslq -0x28(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <testAlloc@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
cmpl   $0x9,-0x14(%rbp)
jle    11e4 <prevodDoVystupni+0x94>
mov    -0x14(%rbp),%eax
add    $0x37,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11f7 <prevodDoVystupni+0xa7>
mov    -0x14(%rbp),%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x28(%rbp)
cmp    $0x0,%edx
jne    1232 <prevodDoVystupni+0xe2>
mov    -0x28(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1070 <realloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <testAlloc@plt>
jmp    1237 <prevodDoVystupni+0xe7>
cmpq   $0x0,-0x8(%rbp)
ja     119f <prevodDoVystupni+0x4f>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1284 <prevodDoVystupni+0x134>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
lea    0xd93(%rip),%rsi
movsbl (%rax,%rcx,1),%edx
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    124b <prevodDoVystupni+0xfb>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prevodDoVystupni>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rbp
mov    $0xa,%r12d
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <testAlloc@plt>
mov    %ebx,0x4(%rsp)
movslq %ebx,%r15
xor    %ebx,%ebx
mov    $0x37,%ecx
jmp    1198 <prevodDoVystupni+0x48>
nopl   0x0(%rax,%rax,1)
cmp    %r15,%rbp
mov    %r13,%rbp
jb     120b <prevodDoVystupni+0xbb>
mov    %rbp,%rax
or     %r15,%rax
shr    $0x20,%rax
je     11c0 <prevodDoVystupni+0x70>
mov    %rbp,%rax
xor    %edx,%edx
div    %r15
mov    %rax,%r13
jmp    11cb <prevodDoVystupni+0x7b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
xor    %edx,%edx
divl   0x4(%rsp)
mov    %eax,%r13d
cmp    $0xa,%edx
mov    $0x30,%eax
cmovge %ecx,%eax
add    %dl,%al
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %ebx,%eax
cltd
idiv   %r12d
test   %edx,%edx
jne    1190 <prevodDoVystupni+0x40>
add    $0xa,%r12d
mov    %r14,%rdi
mov    %r12d,%esi
call   1070 <realloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <testAlloc@plt>
mov    $0x37,%ecx
jmp    1190 <prevodDoVystupni+0x40>
add    $0xffffffffffffffff,%rbx
mov    %ebx,%r12d
add    %r14,%r12
xor    %ebp,%ebp
mov    0x2dc2(%rip),%r13
lea    0xddb(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13),%edi
movsbl (%r12,%rbp,1),%edx
mov    %r15,%rsi
call   1050 <fprintf@plt>
lea    -0x1(%rbp),%rax
add    %ebx,%ebp
test   %ebp,%ebp
mov    %rax,%rbp
jg     1230 <prevodDoVystupni+0xe0>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [3 x i8] c"%c\00"
define void @prevodDoVystupni(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i64 %0, i64* %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i8* null, i8** %7
store i32 10, i32* %8
store i32 0, i32* %9
store i32 10, i32* %9
%10 = load i32, i32* %9
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 1
%13 = trunc i64 %12 to i32
%14 = call i8* @malloc(i32 %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = call i32 @testAlloc(i8* %15)
br label %17
17: ; preds = %61, %2
%18 = load i64, i64* %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = urem i64 %18, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %6
%23 = load i64, i64* %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = udiv i64 %23, %25
store i64 %26, i64* %3
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 9
br i1 %28, label %29, label %37
29: ; preds = %17
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 55
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %7
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 %32, i8* %36
br label %45
37: ; preds = %17
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 48
%40 = trunc i32 %39 to i8
%41 = load i8*, i8** %7
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 %40, i8* %44
br label %45
45: ; preds = %37, %29
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
%48 = load i32, i32* %5
%49 = load i32, i32* %9
%50 = srem i32 %48, %49
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %45
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 10
store i32 %54, i32* %9
%55 = load i8*, i8** %7
%56 = load i32, i32* %9
%57 = call i8* @realloc(i8* %55, i32 %56)
store i8* %57, i8** %7
%58 = load i8*, i8** %7
%59 = call i32 @testAlloc(i8* %58)
br label %60
60: ; preds = %52, %45
br label %61
61: ; preds = %60
%62 = load i64, i64* %3
%63 = icmp ugt i64 %62, 0
br i1 %63, label %17, label %64
64: ; preds = %61
%65 = load i32, i32* %5
%66 = add nsw i32 %65, -1
store i32 %66, i32* %5
br label %67
67: ; preds = %78, %64
%68 = load i32, i32* %5
%69 = icmp sge i32 %68, 0
br i1 %69, label %70, label %81
70: ; preds = %67
%71 = load i32, i32* @stdout
%72 = load i8*, i8** %7
%73 = load i32, i32* %5
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
%76 = load i8, i8* %75
%77 = call i32 @fprintf(i32 %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %76)
br label %78
78: ; preds = %70
%79 = load i32, i32* %5
%80 = add nsw i32 %79, -1
store i32 %80, i32* %5
br label %67
81: ; preds = %67
%82 = load i8*, i8** %7
%83 = call i32 @free(i8* %82)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [3 x i8] c"%c\00"
define void @prevodDoVystupni(i64 %0, i32 %1) {
%3 = tail call dereferenceable_or_null(10) i8* @malloc(i32 10)
%4 = tail call i32 @testAlloc(i8* %3)
%5 = sext i32 %1 to i64
br label %6
6: ; preds = %27, %2
%7 = phi i64 [ %19, %27 ], [ 0, %2 ]
%8 = phi i8* [ %28, %27 ], [ %3, %2 ]
%9 = phi i64 [ %13, %27 ], [ %0, %2 ]
%10 = phi i32 [ %29, %27 ], [ 10, %2 ]
%11 = urem i64 %9, %5
%12 = trunc i64 %11 to i32
%13 = udiv i64 %9, %5
%14 = icmp sgt i32 %12, 9
%15 = trunc i64 %11 to i8
%16 = select i1 %14, i8 55, i8 48
%17 = add i8 %16, %15
%18 = getelementptr inbounds i8, i8* %8, i64 %7
store i8 %17, i8* %18
%19 = add nuw i64 %7, 1
%20 = trunc i64 %19 to i32
%21 = srem i32 %20, %10
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %6
%24 = add nsw i32 %10, 10
%25 = tail call i8* @realloc(i8* %8, i32 %24)
%26 = tail call i32 @testAlloc(i8* %25)
br label %27
27: ; preds = %6, %23
%28 = phi i8* [ %25, %23 ], [ %8, %6 ]
%29 = phi i32 [ %24, %23 ], [ %10, %6 ]
%30 = icmp ult i64 %9, %5
br i1 %30, label %31, label %6
31: ; preds = %27
%32 = and i64 %7, 4294967295
br label %33
33: ; preds = %31, %33
%34 = phi i64 [ %32, %31 ], [ %39, %33 ]
%35 = load i32, i32* @stdout
%36 = getelementptr inbounds i8, i8* %28, i64 %34
%37 = load i8, i8* %36
%38 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %37)
%39 = add nsw i64 %34, -1
%40 = trunc i64 %34 to i32
%41 = icmp sgt i32 %40, 0
br i1 %41, label %33, label %42
42: ; preds = %33
%43 = tail call i32 @free(i8* %28)
ret void
}