#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 *);
main() {
  int m, n, r;
  printf("Podaj dwie liczby calkowite");
  printf(" dodatnie m i n < ");
  scanf("%d %d", &m, &n);
  printf("NWD(%d,%d) = ", m, n);
  r = n % m;
  while (r != 0) {
    n = m;
    m = r;
    r = n % m;
  }
  printf("%d\n", m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a2 <main+0x82>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x10(%rbp)
jmp    117d <main+0x5d>
mov    -0x8(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%esi
cltd
idiv   %esi
test   %edx,%edx
je     1194 <main+0x74>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %esi,%ecx
mov    %edx,%esi
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1180 <main+0x60>
mov    %ecx,(%rsp)
mov    %esi,0x4(%rsp)
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Podaj dwie liczby calkowite\00"
@.str.1 = [19 x i8] c" dodatnie m i n < \00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [14 x i8] c"NWD(%d,%d) = \00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = srem i32 %11, %12
store i32 %13, i32* %4
br label %14
14: ; preds = %17, %0
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i32, i32* %2
store i32 %18, i32* %3
%19 = load i32, i32* %4
store i32 %19, i32* %2
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = srem i32 %20, %21
store i32 %22, i32* %4
br label %14
23: ; preds = %14
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Podaj dwie liczby calkowite\00"
@.str.1 = [19 x i8] c" dodatnie m i n < \00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [14 x i8] c"NWD(%d,%d) = \00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %2
%12 = load i32, i32* %1
%13 = srem i32 %11, %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %0, %15
%16 = phi i32 [ %18, %15 ], [ %13, %0 ]
%17 = phi i32 [ %16, %15 ], [ %12, %0 ]
%18 = srem i32 %17, %16
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %15
20: ; preds = %15
store i32 %17, i32* %2
store i32 %16, i32* %1
br label %21
21: ; preds = %20, %0
%22 = phi i32 [ %16, %20 ], [ %12, %0 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %22)
ret i32 0
}