#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;
  printf("Podaj dwie liczby calkowite");
  printf(" dodatnie m i n < ");
  scanf("%d %d", &m, &n);
  printf("NWD(%d,%d) = ", m, n);
  while (n != m)
    if (n > m)
      n = n - m;
    else
      m = m - n;
  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
cmp    -0x8(%rbp),%eax
je     11a7 <main+0x87>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1199 <main+0x79>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11a2 <main+0x82>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1173 <main+0x53>
mov    -0x8(%rbp),%esi
lea    0xe92(%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
cmp    %esi,%eax
jne    118c <main+0x6c>
mov    %eax,%esi
jmp    119b <main+0x7b>
cs nopw 0x0(%rax,%rax,1)
nop
sub    %eax,%esi
mov    %esi,0x4(%rsp)
mov    %eax,%ecx
cmp    %esi,%ecx
je     119b <main+0x7b>
mov    %eax,%ecx
sub    %esi,%ecx
jle    1180 <main+0x60>
mov    %ecx,(%rsp)
mov    %ecx,%eax
cmp    %esi,%ecx
jne    118c <main+0x6c>
lea    0xea1(%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
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 %8)
br label %10
10: ; preds = %26, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = sub nsw i32 %19, %20
store i32 %21, i32* %3
br label %26
22: ; preds = %14
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = sub nsw i32 %23, %24
store i32 %25, i32* %2
br label %26
26: ; preds = %22, %18
br label %10
27: ; preds = %10
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %28)
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 = icmp eq i32 %11, %12
br i1 %13, label %26, label %14
14: ; preds = %0, %22
%15 = phi i32 [ %24, %22 ], [ %11, %0 ]
%16 = phi i32 [ %23, %22 ], [ %12, %0 ]
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = sub nsw i32 %15, %16
store i32 %19, i32* %2
br label %22
20: ; preds = %14
%21 = sub nsw i32 %16, %15
store i32 %21, i32* %1
br label %22
22: ; preds = %20, %18
%23 = phi i32 [ %21, %20 ], [ %16, %18 ]
%24 = phi i32 [ %15, %20 ], [ %19, %18 ]
%25 = icmp eq i32 %24, %23
br i1 %25, label %26, label %14
26: ; preds = %22, %0
%27 = phi i32 [ %11, %0 ], [ %23, %22 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %27)
ret i32 0
}