#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 *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(void) {
  char c[80] = "!login:pass\0";
  char l[80];
  char *p;
  printf("cadena=%s\n", c + 2);
  p = strchr(c, ':');
  printf("tras buscar : %s\n", p);
  strncpy(l, c + 1, p - c - 1);
  l[p - c - 1] = '\0';
  printf("login=%s\n", l);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x50,%edx
call   1060 <memcpy@plt>
lea    -0x60(%rbp),%rsi
add    $0x2,%rsi
lea    0xeda(%rip),%rdi
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rsi
lea    0xebd(%rip),%rdi
call   1050 <printf@plt>
lea    -0xb0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
add    $0x1,%rsi
mov    -0xb8(%rbp),%rax
lea    -0x60(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0xb8(%rbp),%rax
lea    -0x60(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
movb   $0x0,-0xb0(%rbp,%rax,1)
lea    -0xb0(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
movaps 0xeff(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xee3(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec7(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeab(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe8f(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x2(%rsp),%rsi
lea    0xecf(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,%r14
lea    0xebb(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0x1(%rsp),%rsi
not    %rbx
add    %r14,%rbx
lea    0x50(%rsp),%r14
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x50(%rsp,%rbx,1)
lea    0xe9f(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.c = [80 x i8] c"!login:pass\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [11 x i8] c"cadena=%s\0A\00"
@.str.1 = [18 x i8] c"tras buscar : %s\0A\00"
@.str.2 = [10 x i8] c"login=%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [80 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [80 x i8]* %2 to i8*
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds i8, i8* %6, i64 2
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%10 = call i8* @strchr(i8* %9, i8 signext 58)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8*, i8** %4
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%18 = ptrtoint i8* %16 to i64
%19 = ptrtoint i8* %17 to i64
%20 = sub i64 %18, %19
%21 = sub nsw i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i32 @strncpy(i8* %13, i8* %15, i32 %22)
%24 = load i8*, i8** %4
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%26 = ptrtoint i8* %24 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = sub nsw i64 %28, 1
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %29
store i8 0, i8* %30
%31 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %31)
ret i32 0
}

LLVM IR (-O2):
@__const.main.c = [80 x i8] c"!login:pass\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [11 x i8] c"cadena=%s\0A\00"
@.str.1 = [18 x i8] c"tras buscar : %s\0A\00"
@.str.2 = [10 x i8] c"login=%s\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 2
%6 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = call i8* @strchr(i8* %3, i8 signext 58)
%8 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 1
%10 = ptrtoint i8* %7 to i64
%11 = ptrtoint [80 x i8]* %1 to i64
%12 = xor i64 %11, -1
%13 = add i64 %10, %12
%14 = trunc i64 %13 to i32
%15 = call i32 @strncpy(i8* %4, i8* %9, i32 %14)
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %13
store i8 0, i8* %16
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}