#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 strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
void note_status_replace(char *line, char *old, char *new) {
  char *ptr = NULL;
  ptr = strstr(line, old);
  if (ptr != NULL) {
    int diff = strlen(line) - strlen(ptr);
    if (diff == 2)
      strncpy(ptr, new, 1);
  }
}


x86 assembly (clang, -O0):
<note_status_replace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a8 <note_status_replace+0x78>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jne    11a3 <note_status_replace+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
jmp    11a8 <note_status_replace+0x78>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<note_status_replace>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%rbx
call   1050 <strstr@plt>
test   %rax,%rax
je     1176 <note_status_replace+0x46>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
sub    %eax,%ebx
cmp    $0x2,%ebx
jne    1176 <note_status_replace+0x46>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strncpy@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @note_status_replace(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8* null, i8** %7
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i8* @strstr(i8* %9, i8* %10)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %27
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = load i8*, i8** %7
%18 = call i32 @strlen(i8* %17)
%19 = sub nsw i32 %16, %18
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i8*, i8** %7
%24 = load i8*, i8** %6
%25 = call i32 @strncpy(i8* %23, i8* %24, i32 1)
br label %26
26: ; preds = %22, %14
br label %27
27: ; preds = %26, %3
ret void
}

LLVM IR (-O2):
define void @note_status_replace(i8* %0, i8* nocapture %1, i8* %2) {
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* %4)
%9 = sub nsw i32 %7, %8
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @strncpy(i8* %4, i8* %2, i32 1)
br label %13
13: ; preds = %6, %11, %3
ret void
}