#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 strlen(char *);
void mensagem() {
  char texto[50] = "oi";
  int size = strlen(texto);
  float i = (76 - size) / 2, loop = 0;
  printf("[");
  for (i; i >= 0; i--) {
    printf(" ");
    if (i == 0 && loop < 1) {
      loop++;
      printf("%s", texto);
      i = (78 - size) / 2;
    }
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<mensagem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
movb   $0x6f,-0x40(%rbp)
movb   $0x69,-0x3f(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    $0x4c,%eax
sub    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     122c <mensagem+0xfc>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1210 <mensagem+0xe0>
jp     1210 <mensagem+0xe0>
movss  0xe37(%rip),%xmm0
ucomiss -0x4c(%rbp),%xmm0
jbe    1210 <mensagem+0xe0>
movss  0xe25(%rip),%xmm0
addss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x4e,%eax
sub    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x48(%rbp)
jmp    1215 <mensagem+0xe5>
movss  0xde7(%rip),%xmm0
addss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
jmp    118b <mensagem+0x5b>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mensagem>:
push   %r14
push   %rbx
sub    $0x48,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movw   $0x0,0x40(%rsp)
movw   $0x696f,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    $0x5b,%edi
call   1030 <putchar@plt>
cmp    $0x4d,%ebx
jle    1196 <mensagem+0x56>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x4c,%eax
sub    %ebx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
cvtsi2ss %ecx,%xmm2
mov    $0x4e,%eax
sub    %ebx,%eax
shr    %eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xe41(%rip),%r14
lea    0x10(%rsp),%rbx
xorps  %xmm3,%xmm3
jmp    11f3 <mensagem+0xb3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0x4(%rsp),%xmm3
addss  0xe16(%rip),%xmm2
ucomiss %xmm0,%xmm2
jb     1182 <mensagem+0x42>
movss  %xmm3,0x4(%rsp)
movss  %xmm2,0xc(%rsp)
mov    $0x20,%edi
call   1030 <putchar@plt>
movss  0xc(%rsp),%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm2
jne    11e0 <mensagem+0xa0>
jp     11e0 <mensagem+0xa0>
movss  0xddf(%rip),%xmm1
movss  0x4(%rsp),%xmm3
ucomiss %xmm3,%xmm1
jbe    11e6 <mensagem+0xa6>
addss  %xmm1,%xmm3
movss  %xmm3,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
movss  0x4(%rsp),%xmm3
xorps  %xmm0,%xmm0
movss  0x8(%rsp),%xmm2
jmp    11e6 <mensagem+0xa6>

LLVM IR (-O0):
@.str = [2 x i8] c"[\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"]\0A\00"
define void @mensagem() {
%1 = alloca [50 x i8]
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = bitcast [50 x i8]* %1 to i8*
%6 = bitcast i8* %5 to [50 x i8]*
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i32 0, i32 0
store i8 111, i8* %7
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i32 0, i32 1
store i8 105, i8* %8
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = sub nsw i32 76, %11
%13 = sdiv i32 %12, 2
%14 = sitofp i32 %13 to float
store float %14, float* %3
store float 0.000000e+00, float* %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = load float, float* %3
br label %17
17: ; preds = %37, %0
%18 = load float, float* %3
%19 = fcmp oge float %18, 0.000000e+00
br i1 %19, label %20, label %40
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load float, float* %3
%23 = fcmp oeq float %22, 0.000000e+00
br i1 %23, label %24, label %36
24: ; preds = %20
%25 = load float, float* %4
%26 = fcmp olt float %25, 1.000000e+00
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load float, float* %4
%29 = fadd float %28, 1.000000e+00
store float %29, float* %4
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i32, i32* %2
%33 = sub nsw i32 78, %32
%34 = sdiv i32 %33, 2
%35 = sitofp i32 %34 to float
store float %35, float* %3
br label %36
36: ; preds = %27, %24, %20
br label %37
37: ; preds = %36
%38 = load float, float* %3
%39 = fadd float %38, -1.000000e+00
store float %39, float* %3
br label %17
40: ; preds = %17
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%s\00"
@str = [2 x i8] c"]\00"
define void @mensagem() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
store i8 111, i8* %2
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 1
store i8 105, i8* %3
%4 = call i32 @strlen(i8* %2)
%5 = call i32 @putchar(i32 91)
%6 = icmp sgt i32 %4, 77
br i1 %6, label %29, label %7
7: ; preds = %0
%8 = sub nsw i32 76, %4
%9 = sdiv i32 %8, 2
%10 = sitofp i32 %9 to float
%11 = sub nsw i32 78, %4
%12 = lshr i32 %11, 1
%13 = sitofp i32 %12 to float
br label %14
14: ; preds = %7, %24
%15 = phi float [ 0.000000e+00, %7 ], [ %26, %24 ]
%16 = phi float [ %10, %7 ], [ %27, %24 ]
%17 = call i32 @putchar(i32 32)
%18 = fcmp oeq float %16, 0.000000e+00
%19 = fcmp olt float %15, 1.000000e+00
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = fadd float %15, 1.000000e+00
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %24
24: ; preds = %14, %21
%25 = phi float [ %13, %21 ], [ %16, %14 ]
%26 = phi float [ %22, %21 ], [ %15, %14 ]
%27 = fadd float %25, -1.000000e+00
%28 = fcmp ult float %27, 0.000000e+00
br i1 %28, label %29, label %14
29: ; preds = %24, %0
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}