#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 mult(void) {
  int valor = 0, mult = 1;
  printf("Foi escolhida a multiplicacao:\n\n");
  do {
    printf("Informe os valores desejados e 0 (zero) para concluir:");
    scanf("%d", &valor);
    if (valor == 0)
      break;
    mult *= valor;
  } while (valor != 0);
  return mult;
}


x86 assembly (clang, -O0):
<mult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
jne    116d <mult+0x4d>
jmp    1181 <mult+0x61>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1142 <mult+0x22>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mult>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
mov    $0x1,%ebx
test   %eax,%eax
je     11ae <mult+0x7e>
lea    0xe83(%rip),%r14
lea    0xeb3(%rip),%r15
lea    0x4(%rsp),%r12
nopl   0x0(%rax)
imul   %eax,%ebx
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jne    1190 <mult+0x60>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Foi escolhida a multiplicacao:\0A\0A\00"
@.str.1 = [55 x i8] c"Informe os valores desejados e 0 (zero) para concluir:\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @mult() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %14, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %4
br label %17
10: ; preds = %4
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = mul nsw i32 %12, %11
store i32 %13, i32* %2
br label %14
14: ; preds = %10
%15 = load i32, i32* %1
%16 = icmp ne i32 %15, 0
br i1 %16, label %4, label %17
17: ; preds = %14, %9
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str.1 = [55 x i8] c"Informe os valores desejados e 0 (zero) para concluir:\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [32 x i8] c"Foi escolhida a multiplicacao:\0A\00"
define i32 @mult() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %0, %8
%9 = phi i32 [ %14, %8 ], [ %6, %0 ]
%10 = phi i32 [ %11, %8 ], [ 1, %0 ]
%11 = mul nsw i32 %9, %10
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %8
16: ; preds = %8, %0
%17 = phi i32 [ 1, %0 ], [ %11, %8 ]
ret i32 %17
}