#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);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main() {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  printf("%d\n", (A + B) % C);
  printf("%d\n", (A % C + B % C) % C);
  printf("%d\n", (A * B) % C);
  printf("%d\n", (A % C * B % C) % C);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,%esi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    -0x14(%rbp),%eax
add    %edx,%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,%esi
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,%esi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,%eax
imul   -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,%esi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
add    0xc(%rsp),%eax
cltd
idivl  0x4(%rsp)
lea    0xeb5(%rip),%rbx
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
mov    0x4(%rsp),%esi
cltd
idiv   %esi
mov    %edx,%ecx
mov    0x8(%rsp),%eax
cltd
idiv   %esi
add    %edx,%ecx
mov    %ecx,%eax
cltd
idiv   %esi
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
mov    0x8(%rsp),%eax
imul   0xc(%rsp),%eax
cltd
idivl  0x4(%rsp)
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
mov    0x4(%rsp),%ecx
cltd
idiv   %ecx
mov    %edx,%eax
imul   0x8(%rsp),%eax
cltd
idiv   %ecx
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [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 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = add nsw i32 %6, %7
%9 = load i32, i32* %4
%10 = srem i32 %8, %9
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = srem i32 %12, %13
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = srem i32 %15, %16
%18 = add nsw i32 %14, %17
%19 = load i32, i32* %4
%20 = srem i32 %18, %19
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = mul nsw i32 %22, %23
%25 = load i32, i32* %4
%26 = srem i32 %24, %25
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %2
%29 = load i32, i32* %4
%30 = srem i32 %28, %29
%31 = load i32, i32* %3
%32 = mul nsw i32 %30, %31
%33 = load i32, i32* %4
%34 = srem i32 %32, %33
%35 = load i32, i32* %4
%36 = srem i32 %34, %35
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [4 x i8] c"%d\0A\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 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = add nsw i32 %9, %8
%11 = load i32, i32* %3
%12 = srem i32 %10, %11
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
%15 = load i32, i32* %3
%16 = srem i32 %14, %15
%17 = load i32, i32* %2
%18 = srem i32 %17, %15
%19 = add nsw i32 %18, %16
%20 = srem i32 %19, %15
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = mul nsw i32 %23, %22
%25 = load i32, i32* %3
%26 = srem i32 %24, %25
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %1
%29 = load i32, i32* %3
%30 = srem i32 %28, %29
%31 = load i32, i32* %2
%32 = mul nsw i32 %31, %30
%33 = srem i32 %32, %29
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %33)
ret i32 0
}