#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ system(char *);
int main() {
  system("clear");
  char yazi[100];
  int i;
  int rakam_toplam = 0;
  char s[2];
  printf("icerisinde rakam bulunan bir yazi girin: \n");
  fgets(yazi, 100, stdin);
  yazi[strlen(yazi) - 1] = '\0';
  for (i = 0; yazi[i] != '\0'; i++) {
    if (isdigit(yazi[i])) {
      s[0] = yazi[i];
      s[1] = '\0';
      rakam_toplam += atoi(s);
    }
  }
  printf("rakamlarin toplami: %d\n", rakam_toplam);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
call   1050 <system@plt>
movl   $0x0,-0x78(%rbp)
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1070 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
movl   $0x0,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1226 <main+0xc6>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1213 <main+0xb3>
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x7a(%rbp)
movb   $0x0,-0x79(%rbp)
lea    -0x7a(%rbp),%rdi
call   1080 <atoi@plt>
mov    %rax,%rcx
movslq -0x78(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x78(%rbp)
jmp    1218 <main+0xb8>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11c4 <main+0x64>
mov    -0x78(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
lea    0xe7e(%rip),%rdi
call   1060 <system@plt>
lea    0xe90(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    0x10(%rsp),%al
test   %al,%al
je     1211 <main+0xa1>
lea    0x11(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe(%rsp),%r14
jmp    11eb <main+0x7b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1213 <main+0xa3>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11e0 <main+0x70>
movzbl -0x1(%rbx),%eax
mov    %al,0xe(%rsp)
movb   $0x0,0xf(%rsp)
mov    %r14,%rdi
call   1090 <atoi@plt>
add    %eax,%ebp
jmp    11e0 <main+0x70>
xor    %ebp,%ebp
lea    0xdec(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [43 x i8] c"icerisinde rakam bulunan bir yazi girin: \0A\00"
@stdin = global i32 0
@.str.2 = [24 x i8] c"rakamlarin toplami: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i8]
store i32 0, i32* %1
%6 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %8, i32 100, i32 %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %14
store i8 0, i8* %15
store i32 0, i32* %3
br label %16
16: ; preds = %44, %0
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %47
23: ; preds = %16
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = call i64 @isdigit(i8 signext %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %43
30: ; preds = %23
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
store i8 %34, i8* %35
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
store i8 0, i8* %36
%37 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%38 = call i64 @atoi(i8* %37)
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = add nsw i64 %40, %38
%42 = trunc i64 %41 to i32
store i32 %42, i32* %4
br label %43
43: ; preds = %30, %23
br label %44
44: ; preds = %43
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %16
47: ; preds = %16
%48 = load i32, i32* %4
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@stdin = global i32 0
@.str.2 = [24 x i8] c"rakamlarin toplami: %d\0A\00"
@str = [42 x i8] c"icerisinde rakam bulunan bir yazi girin: \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [2 x i8]
%3 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %4, i32 100, i32 %7)
%9 = call i32 @strlen(i8* %4)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %11
store i8 0, i8* %12
%13 = load i8, i8* %4
%14 = icmp eq i8 %13, 0
br i1 %14, label %35, label %15
15: ; preds = %0
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
br label %17
17: ; preds = %15, %29
%18 = phi i64 [ 0, %15 ], [ %31, %29 ]
%19 = phi i8 [ %13, %15 ], [ %33, %29 ]
%20 = phi i8* [ %4, %15 ], [ %32, %29 ]
%21 = phi i32 [ 0, %15 ], [ %30, %29 ]
%22 = call i64 @isdigit(i8 signext %19)
%23 = icmp eq i64 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %17
%25 = load i8, i8* %20
store i8 %25, i8* %5
store i8 0, i8* %16
%26 = call i64 @atoi(i8* %5)
%27 = trunc i64 %26 to i32
%28 = add i32 %21, %27
br label %29
29: ; preds = %17, %24
%30 = phi i32 [ %28, %24 ], [ %21, %17 ]
%31 = add nuw i64 %18, 1
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %17
35: ; preds = %29, %0
%36 = phi i32 [ 0, %0 ], [ %30, %29 ]
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %36)
ret i32 0
}