#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 matriz[3][3], somalinha[3] = {0};
  for (int i = 0; i < 3; i++) {
    for (int h = 0; h < 3; h++) {
      printf("Digite os valores de uma matriz 3x3:\n");
      scanf("%d", &matriz[i][h]);
      somalinha[i] += matriz[i][h];
    }
    printf("O resultado da soma da linha %d eh %d\n", i, somalinha[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3c(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x3,-0x40(%rbp)
jge    11fc <main+0xcc>
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    11d5 <main+0xa5>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x40(%rbp),%rax
lea    -0x30(%rbp),%rsi
imul   $0xc,%rax,%rax
add    %rax,%rsi
movslq -0x44(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe86(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x40(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x40(%rbp),%rax
add    -0x3c(%rbp,%rax,4),%ecx
mov    %ecx,-0x3c(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1167 <main+0x37>
mov    -0x40(%rbp),%esi
movslq -0x40(%rbp),%rax
mov    -0x3c(%rbp,%rax,4),%edx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1156 <main+0x26>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xee9(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    (%rsp),%ebp
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
add    0x4(%rsp),%ebp
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
add    0x8(%rsp),%ebp
lea    0xe6c(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebp
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
add    0x10(%rsp),%ebp
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
add    0x14(%rsp),%ebp
mov    %r15,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x18(%rsp),%ebp
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x1c(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
add    0x1c(%rsp),%ebp
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
add    0x20(%rsp),%ebp
mov    %r15,%rdi
mov    $0x2,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Digite os valores de uma matriz 3x3:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"O resultado da soma da linha %d eh %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x [3 x i32]]
%3 = alloca [3 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [3 x i32]* %3 to i8*
store i32 0, i32* %4
br label %7
7: ; preds = %45, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %48
10: ; preds = %7
store i32 0, i32* %5
br label %11
11: ; preds = %35, %10
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 %17
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %18, i64 0, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 %24
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [3 x i32], [3 x i32]* %25, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = add nsw i32 %33, %29
store i32 %34, i32* %32
br label %35
35: ; preds = %14
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %11
38: ; preds = %11
%39 = load i32, i32* %4
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %43)
br label %45
45: ; preds = %38
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %7
48: ; preds = %7
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"O resultado da soma da linha %d eh %d\0A\00"
@str = [37 x i8] c"Digite os valores de uma matriz 3x3:\00"
define i32 @main() {
%1 = alloca [3 x [3 x i32]]
%2 = bitcast [3 x [3 x i32]]* %1 to i8*
%3 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%6 = load i32, i32* %4
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%8 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0, i64 1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = load i32, i32* %8
%11 = add nsw i32 %6, %10
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%13 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0, i64 2
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = load i32, i32* %13
%16 = add nsw i32 %11, %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%19 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 1, i64 0
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = load i32, i32* %19
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%23 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 1, i64 1
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = load i32, i32* %23
%26 = add nsw i32 %21, %25
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%28 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 1, i64 2
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
%30 = load i32, i32* %28
%31 = add nsw i32 %26, %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %31)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%34 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 0
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %34)
%36 = load i32, i32* %34
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%38 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 1
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %38)
%40 = load i32, i32* %38
%41 = add nsw i32 %36, %40
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%43 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 2
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %43)
%45 = load i32, i32* %43
%46 = add nsw i32 %41, %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %46)
ret i32 0
}