#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 sayi = 0, toplam = 0;
  printf("4 basamaklı bir sayı giriniz:\n");
  scanf("%d", &sayi);
  toplam += sayi % 10;
  sayi /= 10;
  toplam += sayi % 10;
  sayi /= 10;
  toplam += sayi % 10;
  sayi /= 10;
  toplam += sayi % 10;
  sayi /= 10;
  printf("Basamakların toplam değeri : %d\n", toplam);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%edx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%edx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%edx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%edx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe43(%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
movl   $0x0,0x4(%rsp)
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
movslq 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%r8d
imul   $0x51eb851f,%rax,%r9
imul   $0x10624dd3,%rax,%r10
imul   $0x68db8bad,%rax,%rdx
sub    %r8d,%eax
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rsi
add    %edi,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%ecx
add    %eax,%ecx
mov    %r9,%rax
shr    $0x3f,%rax
sar    $0x25,%r9
add    %eax,%r9d
movslq %r9d,%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rsi
add    %edi,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%eax
add    %ecx,%eax
mov    %r10,%rcx
shr    $0x3f,%rcx
sar    $0x26,%r10
add    %ecx,%r10d
movslq %r10d,%rsi
imul   $0x66666667,%rsi,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rcx
add    %edi,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%esi
add    %eax,%esi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2c,%rdx
add    %eax,%edx
mov    %edx,0x4(%rsp)
lea    0xde1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"4 basamakl\C4\B1 bir say\C4\B1 giriniz:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"Basamaklar\C4\B1n toplam de\C4\9Feri : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = srem i32 %6, 10
%8 = load i32, i32* %3
%9 = add nsw i32 %8, %7
store i32 %9, i32* %3
%10 = load i32, i32* %2
%11 = sdiv i32 %10, 10
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = srem i32 %12, 10
%14 = load i32, i32* %3
%15 = add nsw i32 %14, %13
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 10
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = srem i32 %18, 10
%20 = load i32, i32* %3
%21 = add nsw i32 %20, %19
store i32 %21, i32* %3
%22 = load i32, i32* %2
%23 = sdiv i32 %22, 10
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = srem i32 %24, 10
%26 = load i32, i32* %3
%27 = add nsw i32 %26, %25
store i32 %27, i32* %3
%28 = load i32, i32* %2
%29 = sdiv i32 %28, 10
store i32 %29, i32* %2
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"Basamaklar\C4\B1n toplam de\C4\9Feri : %d\0A\00"
@str = [32 x i8] c"4 basamakl\C4\B1 bir say\C4\B1 giriniz:\00"
define i32 @main() {
%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 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = srem i32 %5, 10
%7 = sdiv i32 %5, 10
%8 = srem i32 %7, 10
%9 = add nsw i32 %8, %6
%10 = sdiv i32 %5, 100
%11 = srem i32 %10, 10
%12 = add nsw i32 %9, %11
%13 = sdiv i32 %5, 1000
%14 = srem i32 %13, 10
%15 = add nsw i32 %12, %14
%16 = sdiv i32 %5, 10000
store i32 %16, i32* %1
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %15)
ret i32 0
}