#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 divisao(int, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int resto, dividendo, divisor, d;
  printf("entre com dividendo: ");
  scanf("%d", &dividendo);
  do {
    printf("entre com divisor: ");
    scanf("%d", &divisor);
  } while (divisor == 0);
  d = divisao(dividendo, divisor, &resto);
  printf("Resultado:%d - Resto:%d", d, resto);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
je     115d <main+0x2d>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
lea    -0x8(%rbp),%rdx
call   1030 <divisao@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef1(%rip),%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
lea    0xeb4(%rip),%r15
lea    0x4(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     1170 <main+0x40>
mov    0x8(%rsp),%edi
lea    0xc(%rsp),%rdx
call   1030 <divisao@plt>
mov    0xc(%rsp),%edx
lea    0xe84(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"entre com dividendo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"entre com divisor: \00"
@.str.3 = [24 x i8] c"Resultado:%d - Resto:%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %8
8: ; preds = %11, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %11
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 0
br i1 %13, label %8, label %14
14: ; preds = %11
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 @divisao(i32 %15, i32 %16, i32* %2)
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"entre com dividendo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"entre com divisor: \00"
@.str.3 = [24 x i8] c"Resultado:%d - Resto:%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %9, %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %9, label %14
14: ; preds = %9
%15 = load i32, i32* %2
%16 = call i32 @divisao(i32 %15, i32 %12, i32* %1)
%17 = load i32, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %16, i32 %17)
ret i32 0
}