#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
main() {
  system("title 27_Cascallar_Autrán_Manuel");
  system("color 0A");
  system("cls");
  printf("EQUIVALENTE DUN DECIMAL NOUTRA BASE\n");
  printf("===================================\n");
  int num, base, resto[8], i, a;
  i = 0;
  do {
    printf("Introducir o n\243mero decimal:\n");
    scanf("%d", &num);
    printf("Introduce a base:\n");
    scanf("%d", &base);
    if (num != 0 && base != 0) {
      for (a = 0; a < 8; a++) {
        resto[i] = num % base;
        num = num / base;
        i++;
      }
      for (i = 7; i >= 0; i--) {
        printf("%d", resto[i]);
      }
    }
  } while (num != 0 && base != 0);
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <system@plt>
lea    0xed0(%rip),%rdi
call   1030 <system@plt>
lea    0xecd(%rip),%rdi
call   1030 <system@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x34(%rbp)
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xefc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1251 <main+0x121>
cmpl   $0x0,-0xc(%rbp)
je     1251 <main+0x121>
movl   $0x0,-0x38(%rbp)
cmpl   $0x8,-0x38(%rbp)
jge    1217 <main+0xe7>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
movslq -0x34(%rbp),%rax
mov    %edx,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x8(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11dd <main+0xad>
movl   $0x7,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     124c <main+0x11c>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    121e <main+0xee>
jmp    1251 <main+0x121>
jmp    1256 <main+0x126>
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x39(%rbp)
je     126f <main+0x13f>
cmpl   $0x0,-0xc(%rbp)
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    1186 <main+0x56>
lea    0xe2c(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xeab(%rip),%rdi
call   1040 <system@plt>
lea    0xec1(%rip),%rdi
call   1040 <system@plt>
lea    0xebe(%rip),%rdi
call   1040 <system@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeef(%rip),%r14
lea    0xe97(%rip),%rbx
lea    0x8(%rsp),%r15
lea    0xef9(%rip),%r12
lea    0xc(%rsp),%r13
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
test   %eax,%eax
je     12aa <main+0x16a>
test   %ecx,%ecx
je     12aa <main+0x16a>
cltd
idiv   %ecx
movslq %ebp,%rsi
mov    %edx,0x10(%rsp,%rsi,4)
cltd
idiv   %ecx
mov    %edx,0x14(%rsp,%rsi,4)
cltd
idiv   %ecx
mov    %edx,0x18(%rsp,%rsi,4)
cltd
idiv   %ecx
mov    %edx,0x1c(%rsp,%rsi,4)
cltd
idiv   %ecx
mov    %edx,0x20(%rsp,%rsi,4)
cltd
idiv   %ecx
mov    %edx,0x24(%rsp,%rsi,4)
cltd
idiv   %ecx
mov    %edx,0x28(%rsp,%rsi,4)
cltd
idiv   %ecx
mov    %edx,0x2c(%rsp,%rsi,4)
mov    %eax,0x8(%rsp)
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%eax
mov    $0xffffffff,%ebp
mov    0xc(%rsp),%ecx
test   %eax,%eax
je     12b6 <main+0x176>
test   %ecx,%ecx
jne    11b0 <main+0x70>
lea    0xd75(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"title 27_Cascallar_Autr\C3\A1n_Manuel\00"
@.str.1 = [9 x i8] c"color 0A\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.3 = [37 x i8] c"EQUIVALENTE DUN DECIMAL NOUTRA BASE\0A\00"
@.str.4 = [37 x i8] c"===================================\0A\00"
@.str.5 = [30 x i8] c"Introducir o n\A3mero decimal:\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [19 x i8] c"Introduce a base:\0A\00"
@.str.8 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [8 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %5
br label %12
12: ; preds = %62, %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %55
19: ; preds = %12
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %55
22: ; preds = %19
store i32 0, i32* %6
br label %23
23: ; preds = %38, %22
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 8
br i1 %25, label %26, label %41
26: ; preds = %23
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = srem i32 %27, %28
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %31
store i32 %29, i32* %32
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = sdiv i32 %33, %34
store i32 %35, i32* %2
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %38
38: ; preds = %26
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %23
41: ; preds = %23
store i32 7, i32* %5
br label %42
42: ; preds = %51, %41
%43 = load i32, i32* %5
%44 = icmp sge i32 %43, 0
br i1 %44, label %45, label %54
45: ; preds = %42
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %45
%52 = load i32, i32* %5
%53 = add nsw i32 %52, -1
store i32 %53, i32* %5
br label %42
54: ; preds = %42
br label %55
55: ; preds = %54, %19, %12
br label %56
56: ; preds = %55
%57 = load i32, i32* %2
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32, i32* %3
%61 = icmp ne i32 %60, 0
br label %62
62: ; preds = %59, %56
%63 = phi i1 [ false, %56 ], [ %61, %59 ]
br i1 %63, label %12, label %64
64: ; preds = %62
%65 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@.str = [34 x i8] c"title 27_Cascallar_Autr\C3\A1n_Manuel\00"
@.str.1 = [9 x i8] c"color 0A\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.8 = [6 x i8] c"pause\00"
@str = [36 x i8] c"EQUIVALENTE DUN DECIMAL NOUTRA BASE\00"
@str.9 = [36 x i8] c"===================================\00"
@str.10 = [29 x i8] c"Introducir o n\A3mero decimal:\00"
@str.11 = [18 x i8] c"Introduce a base:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [8 x i32]
%4 = tail call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.9, i64 0, i64 0))
%9 = bitcast i32* %1 to i8*
%10 = bitcast i32* %2 to i8*
%11 = bitcast [8 x i32]* %3 to i8*
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 7
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 6
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 5
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 4
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 3
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 2
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 1
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
br label %20
20: ; preds = %82, %0
%21 = phi i32 [ 0, %0 ], [ %85, %82 ]
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.10, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.11, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%26 = load i32, i32* %1
%27 = icmp ne i32 %26, 0
%28 = load i32, i32* %2
%29 = icmp ne i32 %28, 0
%30 = select i1 %27, i1 %29, i1 false
br i1 %30, label %31, label %82
31: ; preds = %20
%32 = sext i32 %21 to i64
%33 = srem i32 %26, %28
%34 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %32
store i32 %33, i32* %34
%35 = sdiv i32 %26, %28
%36 = add nsw i64 %32, 1
%37 = srem i32 %35, %28
%38 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %36
store i32 %37, i32* %38
%39 = sdiv i32 %35, %28
%40 = add nsw i64 %32, 2
%41 = srem i32 %39, %28
%42 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %40
store i32 %41, i32* %42
%43 = sdiv i32 %39, %28
%44 = add nsw i64 %32, 3
%45 = srem i32 %43, %28
%46 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %44
store i32 %45, i32* %46
%47 = sdiv i32 %43, %28
%48 = add nsw i64 %32, 4
%49 = srem i32 %47, %28
%50 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %48
store i32 %49, i32* %50
%51 = sdiv i32 %47, %28
%52 = add nsw i64 %32, 5
%53 = srem i32 %51, %28
%54 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %52
store i32 %53, i32* %54
%55 = sdiv i32 %51, %28
%56 = add nsw i64 %32, 6
%57 = srem i32 %55, %28
%58 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %56
store i32 %57, i32* %58
%59 = sdiv i32 %55, %28
%60 = add nsw i64 %32, 7
%61 = srem i32 %59, %28
%62 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %60
store i32 %61, i32* %62
%63 = sdiv i32 %59, %28
store i32 %63, i32* %1
%64 = load i32, i32* %12
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %64)
%66 = load i32, i32* %13
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %66)
%68 = load i32, i32* %14
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %68)
%70 = load i32, i32* %15
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %70)
%72 = load i32, i32* %16
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %72)
%74 = load i32, i32* %17
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %74)
%76 = load i32, i32* %18
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %76)
%78 = load i32, i32* %19
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %78)
%80 = load i32, i32* %1
%81 = load i32, i32* %2
br label %82
82: ; preds = %31, %20
%83 = phi i32 [ %28, %20 ], [ %81, %31 ]
%84 = phi i32 [ %26, %20 ], [ %80, %31 ]
%85 = phi i32 [ %21, %20 ], [ -1, %31 ]
%86 = icmp ne i32 %84, 0
%87 = icmp ne i32 %83, 0
%88 = select i1 %86, i1 %87, i1 false
br i1 %88, label %20, label %89
89: ; preds = %82
%90 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}