#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
unsigned long int prevodDoDesitkove(int s1, char cislo[], unsigned int delka) {
  unsigned int i;
  unsigned int hodnota;
  unsigned long int desCislo = 0, zalozniVysledek;
  for (i = 0; i < (delka - 1); i++) {
    if (cislo[i] < 'A') {
      hodnota = cislo[i] - '0';
    } else {
      hodnota = cislo[i] - '7';
    }
    zalozniVysledek = desCislo;
    desCislo *= s1;
    desCislo += hodnota;
    if ((desCislo / s1) != zalozniVysledek) {
      fprintf(stderr, "Doslo k chybe preteceni.\n");
      free(cislo);
      exit(EXIT_FAILURE);
    }
  }
  return desCislo;
}


x86 assembly (clang, -O0):
<prevodDoDesitkove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jae    1213 <prevodDoDesitkove+0xe3>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x41,%eax
jge    118c <prevodDoDesitkove+0x5c>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x1c(%rbp)
jmp    119d <prevodDoDesitkove+0x6d>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
sub    $0x37,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
movslq -0x4(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
xor    %edx,%edx
div    %rcx
cmp    -0x30(%rbp),%rax
je     1200 <prevodDoDesitkove+0xd0>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe1c(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    1205 <prevodDoDesitkove+0xd5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1151 <prevodDoDesitkove+0x21>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prevodDoDesitkove>:
push   %r14
push   %rbx
push   %rax
add    $0xffffffff,%edx
je     11a9 <prevodDoDesitkove+0x79>
mov    %rsi,%r14
mov    $0xffffffc9,%eax
movslq %edi,%r10
mov    %edx,%r8d
xor    %ebx,%ebx
lea    0x7(%rax),%r9d
xor    %esi,%esi
nop
movsbl (%r14,%rbx,1),%eax
cmp    $0x41,%eax
mov    $0xffffffc9,%ecx
cmovl  %r9d,%ecx
add    %eax,%ecx
mov    %rsi,%rax
imul   %r10,%rax
add    %rax,%rcx
mov    %rcx,%rax
or     %r10,%rax
shr    $0x20,%rax
je     1190 <prevodDoDesitkove+0x60>
mov    %rcx,%rax
xor    %edx,%edx
div    %r10
cmp    %rsi,%rax
je     119b <prevodDoDesitkove+0x6b>
jmp    11b6 <prevodDoDesitkove+0x86>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
cmp    %rsi,%rax
jne    11b6 <prevodDoDesitkove+0x86>
add    $0x1,%rbx
mov    %rcx,%rsi
cmp    %rbx,%r8
jne    1150 <prevodDoDesitkove+0x20>
jmp    11ab <prevodDoDesitkove+0x7b>
xor    %ecx,%ecx
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xe3a(%rip),%rsi
call   1040 <fprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Doslo k chybe preteceni.\0A\00"
@EXIT_FAILURE = global i32 0
define i64 @prevodDoDesitkove(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i64 0, i64* %9
store i32 0, i32* %7
br label %11
11: ; preds = %64, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = sub i32 %13, 1
%15 = icmp ult i32 %12, %14
br i1 %15, label %16, label %67
16: ; preds = %11
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp slt i32 %22, 65
br i1 %23, label %24, label %32
24: ; preds = %16
%25 = load i8*, i8** %5
%26 = load i32, i32* %7
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %30, 48
store i32 %31, i32* %8
br label %40
32: ; preds = %16
%33 = load i8*, i8** %5
%34 = load i32, i32* %7
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 55
store i32 %39, i32* %8
br label %40
40: ; preds = %32, %24
%41 = load i64, i64* %9
store i64 %41, i64* %10
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = load i64, i64* %9
%45 = mul i64 %44, %43
store i64 %45, i64* %9
%46 = load i32, i32* %8
%47 = zext i32 %46 to i64
%48 = load i64, i64* %9
%49 = add i64 %48, %47
store i64 %49, i64* %9
%50 = load i64, i64* %9
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = udiv i64 %50, %52
%54 = load i64, i64* %10
%55 = icmp ne i64 %53, %54
br i1 %55, label %56, label %63
56: ; preds = %40
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%59 = load i8*, i8** %5
%60 = call i32 @free(i8* %59)
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %40
br label %64
64: ; preds = %63
%65 = load i32, i32* %7
%66 = add i32 %65, 1
store i32 %66, i32* %7
br label %11
67: ; preds = %11
%68 = load i64, i64* %9
ret i64 %68
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Doslo k chybe preteceni.\0A\00"
@EXIT_FAILURE = global i32 0
define i64 @prevodDoDesitkove(i32 %0, i8* nocapture %1, i32 %2) {
%4 = add i32 %2, -1
%5 = icmp eq i32 %4, 0
br i1 %5, label %32, label %6
6: ; preds = %3
%7 = sext i32 %0 to i64
%8 = zext i32 %4 to i64
br label %11
9: ; preds = %11
%10 = icmp eq i64 %25, %8
br i1 %10, label %32, label %11
11: ; preds = %6, %9
%12 = phi i64 [ 0, %6 ], [ %25, %9 ]
%13 = phi i64 [ 0, %6 ], [ %22, %9 ]
%14 = getelementptr inbounds i8, i8* %1, i64 %12
%15 = load i8, i8* %14
%16 = sext i8 %15 to i64
%17 = icmp slt i8 %15, 65
%18 = select i1 %17, i64 4294967248, i64 4294967241
%19 = add nsw i64 %18, %16
%20 = mul i64 %13, %7
%21 = and i64 %19, 4294967295
%22 = add i64 %21, %20
%23 = udiv i64 %22, %7
%24 = icmp eq i64 %23, %13
%25 = add nuw nsw i64 %12, 1
br i1 %24, label %9, label %26
26: ; preds = %11
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%29 = tail call i32 @free(i8* %1)
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %9, %3
%33 = phi i64 [ 0, %3 ], [ %22, %9 ]
ret i64 %33
}